participant left group

Former-commit-id: 4964542146
This commit is contained in:
michaelr 2016-04-11 23:12:47 +03:00
parent e28add5118
commit a31231554e
2 changed files with 16 additions and 5 deletions

View File

@ -152,6 +152,13 @@
:content (str (or remover-name from) " removed you from group chat")
:content-type text-content-type})))
(defn participant-left-group-msg [chat-id from msg-id]
(let [left-name (:name (contacts/contact-by-identity from))]
(save-message chat-id {:from "system"
:msg-id msg-id
:content (str (or left-name from) " left")
:content-type text-content-type})))
(defn removed-participant-msg [chat-id identity]
(let [contact-name (:name (contacts/contact-by-identity identity))]
(save-message chat-id {:from "system"
@ -185,6 +192,12 @@
(set-chat-active group-id false)
(signal-chat-updated db group-id)))
(register-handler :participant-left-group
(fn [db [action from group-id msg-id]]
(log/debug action msg-id from group-id)
(participant-left-group-msg group-id from msg-id)
(signal-chat-updated db group-id)))
(register-handler :participant-invited-to-group
(fn [db [action from group-id identity msg-id]]
(log/debug action msg-id from group-id identity)

View File

@ -38,8 +38,6 @@
(dispatch [:participant-removed-from-group from group-id identity msg-id]))
:removed-from-group (let [{:keys [group-id from msg-id]} event]
(dispatch [:you-removed-from-group from group-id msg-id]))
;:participant-left-group (let [{:keys [group-id from]} event]
; (add-to-chat "group-chat" ":" (str (shorten from) " left group chat")))
;(add-to-chat "chat" ":" (str "Don't know how to handle " event-type))
(log/info "Don't know how to handle" event-type)
))})
:participant-left-group (let [{:keys [group-id from msg-id]} event]
(dispatch [:participant-left-group from group-id msg-id]))
(log/info "Don't know how to handle" event-type)))})