add name to group-invite msg

This commit is contained in:
michaelr 2016-04-04 16:59:01 +03:00
parent 47fe0fde28
commit ca254ca2f0
2 changed files with 21 additions and 18 deletions

View File

@ -102,23 +102,25 @@
:content-type default-content-type}})) :content-type default-content-type}}))
(defn start-group-chat (defn start-group-chat
[identities] ([identities]
(let [group-topic (random/id) (start-group-chat identities nil))
keypair (new-keypair) ([identities group-name]
store (storage) (let [group-topic (random/id)
connection (connection) keypair (new-keypair)
my-identity (state/my-identity) store (storage)
identities (-> (set identities) connection (connection)
(conj my-identity))] my-identity (state/my-identity)
(save-keypair store group-topic keypair) identities (-> (set identities)
(save-identities store group-topic identities) (conj my-identity))]
(save-group-admin store group-topic my-identity) (save-keypair store group-topic keypair)
(listen connection handle-incoming-whisper-msg {:topics [group-topic]}) (save-identities store group-topic identities)
(doseq [ident identities :when (not (= ident my-identity))] (save-group-admin store group-topic my-identity)
(let [{:keys [msg-id msg]} (init-group-chat-msg ident group-topic identities keypair)] (listen connection handle-incoming-whisper-msg {:topics [group-topic]})
(add-pending-message msg-id msg {:internal? true}) (doseq [ident identities :when (not (= ident my-identity))]
(post-msg connection msg))) (let [{:keys [msg-id msg]} (init-group-chat-msg ident group-topic identities keypair group-name)]
group-topic)) (add-pending-message msg-id msg {:internal? true})
(post-msg connection msg)))
group-topic)))
(defn group-add-participant (defn group-add-participant
"Only call if you are the group-admin" "Only call if you are the group-admin"

View File

@ -25,11 +25,12 @@
(post-msg (connection) msg) (post-msg (connection) msg)
new-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) (make-msg {:from (state/my-identity)
:to to :to to
:payload {:type :init-group-chat :payload {:type :init-group-chat
:group-topic group-topic :group-topic group-topic
:group-name group-name
:identities identities :identities identities
:keypair keypair}})) :keypair keypair}}))