receive group msg

Former-commit-id: b7ce3df93d
This commit is contained in:
michaelr 2016-04-04 17:19:21 +03:00
parent d0f882d8a7
commit d1180f9d4e
3 changed files with 15 additions and 6 deletions

View File

@ -102,6 +102,12 @@
(create-chat chat-id [chat-id] false)
(signal-chat-updated chat-id))))
(register-handler :group-received-msg
(fn [db [action {chat-id :group-id :as msg}]]
(log/debug action "msg" msg)
(save-message chat-id msg)
(signal-chat-updated db chat-id)))
(register-handler :acked-msg
(fn [db [_ from msg-id]]
(update-message! {:msg-id msg-id

View File

@ -5,7 +5,8 @@
[syng-im.db :as db]
[syng-im.utils.logging :as log]))
(defn save-message [chat-id {:keys [from to msg-id content content-type outgoing] :or {outgoing false} :as msg}]
(defn save-message [chat-id {:keys [from to msg-id content content-type outgoing] :or {outgoing false
to nil} :as msg}]
(when-not (r/exists? :msgs :msg-id msg-id)
(r/write
(fn []

View File

@ -23,11 +23,13 @@
(dispatch [:msg-delivery-failed msg-id]))
:new-group-chat (let [{:keys [from group-id identities group-name]} event]
(dispatch [:group-chat-invite-received from group-id identities group-name]))
:new-group-msg (let [{from :from
group-id :group-id
payload :payload} event]
(dispatch [:group-received-msg (assoc payload :from from
:group-id group-id)]))
;: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
; {content :content} :payload} event]
; (add-to-chat "group-chat" from content))
;:group-new-participant (let [{:keys [group-id identity from]} event]
; (add-to-chat "group-chat" ":" (str (shorten from) " added " (shorten identity) " to group chat"))
; (add-identity-to-group-list identity))