From a31231554ee524dd630740490bf240df81479aab Mon Sep 17 00:00:00 2001 From: michaelr Date: Mon, 11 Apr 2016 23:12:47 +0300 Subject: [PATCH] participant left group Former-commit-id: 49645421460dfb1a1658d5b7b96f1feb325cff36 --- src/syng_im/handlers.cljs | 13 +++++++++++++ src/syng_im/protocol/protocol_handler.cljs | 8 +++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/syng_im/handlers.cljs b/src/syng_im/handlers.cljs index a4b6878830..76077ab3b6 100644 --- a/src/syng_im/handlers.cljs +++ b/src/syng_im/handlers.cljs @@ -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) diff --git a/src/syng_im/protocol/protocol_handler.cljs b/src/syng_im/protocol/protocol_handler.cljs index c6556b4864..8bb19c8f09 100644 --- a/src/syng_im/protocol/protocol_handler.cljs +++ b/src/syng_im/protocol/protocol_handler.cljs @@ -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)))})