accept group chat invitations

Former-commit-id: d4561939d3
This commit is contained in:
michaelr 2016-04-04 17:03:40 +03:00
parent a504c1b861
commit d0f882d8a7
3 changed files with 13 additions and 12 deletions

View File

@ -99,7 +99,7 @@
(log/debug action "msg" msg)
(save-message chat-id msg)
(-> db
(create-chat chat-id [chat-id])
(create-chat chat-id [chat-id] false)
(signal-chat-updated chat-id))))
(register-handler :acked-msg
@ -225,11 +225,15 @@
(log/debug action)
(let [identities (-> (new-group-selection db)
(vec))
group-id (api/start-group-chat identities)
db (create-chat db group-id identities group-name)]
group-id (api/start-group-chat identities group-name)
db (create-chat db group-id identities true group-name)]
(dispatch [:show-chat group-id navigator])
db)))
(register-handler :group-chat-invite-received
(fn [db [action from group-id identities group-name]]
(log/debug action from group-id identities)
(create-chat db group-id identities true group-name)))
(comment

View File

@ -30,9 +30,9 @@
chat-id))
(defn create-chat
([db chat-id identities]
(create-chat db chat-id identities nil))
([db chat-id identities chat-name]
([db chat-id identities group-chat?]
(create-chat db chat-id identities group-chat? nil))
([db chat-id identities group-chat? chat-name]
(if (r/exists? :chats :chat-id chat-id)
db
(let [chat-name (or chat-name
@ -40,8 +40,7 @@
_ (log/debug "creating chat" chat-name)]
(r/write
(fn []
(let [group-chat? (> (count identities) 1)
contacts (mapv (fn [ident]
(let [contacts (mapv (fn [ident]
{:identity ident}) identities)]
(r/create :chats {:chat-id chat-id
:name chat-name

View File

@ -21,10 +21,8 @@
(dispatch [:acked-msg from msg-id]))
:delivery-failed (let [{:keys [msg-id]} event]
(dispatch [:msg-delivery-failed msg-id]))
;:new-group-chat (let [{:keys [from group-id identities]} event]
; (set-group-id! group-id)
; (set-group-identities identities)
; (add-to-chat "group-chat" ":" (str "Received group chat invitation from " from " for group-id: " group-id)))
:new-group-chat (let [{:keys [from group-id identities group-name]} event]
(dispatch [:group-chat-invite-received from group-id identities group-name]))
;:group-chat-invite-acked (let [{:keys [from group-id]} event]
; (add-to-chat "group-chat" ":" (str "Received ACK for group chat invitation from " from " for group-id: " group-id)))
;:new-group-msg (let [{from :from