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)))})