avoid sending 1-to-1 messages to dapps over shh

This commit is contained in:
Roman Volosovskyi 2017-05-01 10:14:05 +03:00
parent 73965c70d7
commit de2e4d105b
2 changed files with 11 additions and 9 deletions

View File

@ -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!))

View File

@ -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])