[fix 7332] error pop-up when sending tx from wallet

when the last used chat was a public chat, the public-key of
the recipient to populate the `:to` key in the notification data
was taken from `:current-chat-id`in app-db.

this fix ensures that the right chat-id (the actual public-key of
the contact) is used instead of current-chat-id by changing the arity
of `send-push-notification`

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
yenda 2019-01-30 12:41:02 +01:00 committed by Igor Mandrigin
parent 093f7de1aa
commit 7985ee838e
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
2 changed files with 4 additions and 4 deletions

View File

@ -382,11 +382,11 @@
(add-own-status chat-id message-id :sending) (add-own-status chat-id message-id :sending)
(send chat-id message-id wrapped-record)))) (send chat-id message-id wrapped-record))))
(fx/defn send-push-notification [cofx message-id fcm-token status] (fx/defn send-push-notification [cofx chat-id message-id fcm-token status]
(log/debug "#6772 - send-push-notification" message-id fcm-token) (log/debug "#6772 - send-push-notification" message-id fcm-token)
(when (and fcm-token (= status :sent)) (when (and fcm-token (= status :sent))
(let [payload {:from (accounts.db/current-public-key cofx) (let [payload {:from (accounts.db/current-public-key cofx)
:to (get-in cofx [:db :current-chat-id]) :to chat-id
:id message-id}] :id message-id}]
{:send-notification {:data-payload (notifications/encode-notification-payload payload) {:send-notification {:data-payload (notifications/encode-notification-payload payload)
:tokens [fcm-token]}}))) :tokens [fcm-token]}})))

View File

@ -87,7 +87,7 @@
(fx/merge cofx (fx/merge cofx
(remove-hash envelope-hash) (remove-hash envelope-hash)
(check-confirmations status chat-id message-id) (check-confirmations status chat-id message-id)
(models.message/send-push-notification message-id fcm-token status))))))) (models.message/send-push-notification chat-id message-id fcm-token status)))))))
(fx/defn set-contact-message-envelope-hash (fx/defn set-contact-message-envelope-hash
[{:keys [db] :as cofx} chat-id envelope-hash] [{:keys [db] :as cofx} chat-id envelope-hash]