From ca254ca2f06b02e9776c2eebdc9cfe4a7545cc42 Mon Sep 17 00:00:00 2001 From: michaelr Date: Mon, 4 Apr 2016 16:59:01 +0300 Subject: [PATCH] add name to group-invite msg --- protocol/src/cljs/syng_im/protocol/api.cljs | 36 ++++++++++--------- .../src/cljs/syng_im/protocol/group_chat.cljs | 3 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/protocol/src/cljs/syng_im/protocol/api.cljs b/protocol/src/cljs/syng_im/protocol/api.cljs index 5b8e9d5..f17bf1b 100644 --- a/protocol/src/cljs/syng_im/protocol/api.cljs +++ b/protocol/src/cljs/syng_im/protocol/api.cljs @@ -102,23 +102,25 @@ :content-type default-content-type}})) (defn start-group-chat - [identities] - (let [group-topic (random/id) - keypair (new-keypair) - store (storage) - connection (connection) - my-identity (state/my-identity) - identities (-> (set identities) - (conj my-identity))] - (save-keypair store group-topic keypair) - (save-identities store group-topic identities) - (save-group-admin store group-topic my-identity) - (listen connection handle-incoming-whisper-msg {:topics [group-topic]}) - (doseq [ident identities :when (not (= ident my-identity))] - (let [{:keys [msg-id msg]} (init-group-chat-msg ident group-topic identities keypair)] - (add-pending-message msg-id msg {:internal? true}) - (post-msg connection msg))) - group-topic)) + ([identities] + (start-group-chat identities nil)) + ([identities group-name] + (let [group-topic (random/id) + keypair (new-keypair) + store (storage) + connection (connection) + my-identity (state/my-identity) + identities (-> (set identities) + (conj my-identity))] + (save-keypair store group-topic keypair) + (save-identities store group-topic identities) + (save-group-admin store group-topic my-identity) + (listen connection handle-incoming-whisper-msg {:topics [group-topic]}) + (doseq [ident identities :when (not (= ident my-identity))] + (let [{:keys [msg-id msg]} (init-group-chat-msg ident group-topic identities keypair group-name)] + (add-pending-message msg-id msg {:internal? true}) + (post-msg connection msg))) + group-topic))) (defn group-add-participant "Only call if you are the group-admin" diff --git a/protocol/src/cljs/syng_im/protocol/group_chat.cljs b/protocol/src/cljs/syng_im/protocol/group_chat.cljs index e969968..25fd9ab 100644 --- a/protocol/src/cljs/syng_im/protocol/group_chat.cljs +++ b/protocol/src/cljs/syng_im/protocol/group_chat.cljs @@ -25,11 +25,12 @@ (post-msg (connection) msg) new-msg)) -(defn init-group-chat-msg [to group-topic identities keypair] +(defn init-group-chat-msg [to group-topic identities keypair group-name] (make-msg {:from (state/my-identity) :to to :payload {:type :init-group-chat :group-topic group-topic + :group-name group-name :identities identities :keypair keypair}}))