From de2e4d105b5079c2b552b29a5118e6c949e8b861 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 1 May 2017 10:14:05 +0300 Subject: [PATCH] avoid sending 1-to-1 messages to dapps over shh --- src/status_im/chat/handlers.cljs | 16 +++++++++------- src/status_im/chat/handlers/send_message.cljs | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index f5c32eb479..6b41a258bb 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -415,9 +415,9 @@ ((after delete-chat!)))) (defn send-seen! - [{:keys [web3 current-public-key chats]} + [{:keys [web3 current-public-key chats contacts]} [_ {:keys [from chat-id message-id]}]] - (when-not (console? chat-id) + (when-not (get-in contacts [chat-id :dapp?]) (let [{:keys [group-chat public?]} (chats chat-id)] (when-not public? (protocol/send-seen! {:web3 web3 @@ -435,11 +435,13 @@ (u/side-effect! send-seen!)) (defn send-clock-value-request! - [{:keys [web3 current-public-key]} [_ {:keys [message-id from]}]] - (protocol/send-clock-value-request! {:web3 web3 - :message {:from current-public-key - :to from - :message-id message-id}})) + [{:keys [web3 current-public-key contacts]} [_ {:keys [message-id from]}]] + (when-not (get-in contacts [from :dapp?]) + (protocol/send-clock-value-request! + {:web3 web3 + :message {:from current-public-key + :to from + :message-id message-id}}))) (register-handler :send-clock-value-request! (u/side-effect! send-clock-value-request!)) diff --git a/src/status_im/chat/handlers/send_message.cljs b/src/status_im/chat/handlers/send_message.cljs index 1686c95cde..6d6053a6a6 100644 --- a/src/status_im/chat/handlers/send_message.cljs +++ b/src/status_im/chat/handlers/send_message.cljs @@ -272,10 +272,10 @@ (register-handler ::send-command-protocol! (u/side-effect! (fn [{:keys [web3 current-public-key chats network-status - current-account-id accounts] :as db} + current-account-id accounts contacts] :as db} [_ {:keys [chat-id command]}]] (log/debug "sending command: " command) - (when (cu/not-console? chat-id) + (when (not (get-in contacts [chat-id :dapp?])) (let [{:keys [public-key private-key]} (chats chat-id) {:keys [group-chat public?]} (get-in db [:chats chat-id])