diff --git a/src/status_im/notifications/local.cljs b/src/status_im/notifications/local.cljs index 3f0c6c3b9d..0893e318d9 100644 --- a/src/status_im/notifications/local.cljs +++ b/src/status_im/notifications/local.cljs @@ -17,7 +17,8 @@ [status-im.ui.screens.chat.components.reply :as reply] [clojure.string :as clojure.string] [status-im.chat.models :as chat.models] - [status-im.constants :as constants])) + [status-im.constants :as constants] + [status-im.utils.identicon :as identicon])) (def default-erc20-token {:symbol :ERC20 @@ -107,30 +108,36 @@ :user-info notification :message description})) +(defn chat-by-message + [{:keys [chats]} {:keys [localChatId from]}] + (if-let [chat (get chats localChatId)] + (assoc chat :chat-id localChatId) + (assoc (get chats from) :chat-id from))) + (defn show-message-pn? - [{{:keys [app-state multiaccount]} :db :as cofx} - {{:keys [message chat]} :body}] - (let [chat-id (get chat :id) - chat-type (get chat :chatType)] - (and - (or (= app-state "background") - (not (chat.models/foreground-chat? cofx chat-id))) - (or (contains? #{constants/one-to-one-chat-type - constants/private-group-chat-type} - chat-type) - (contains? (set (get message :mentions)) - (get multiaccount :public-key)))))) + [{{:keys [app-state]} :db :as cofx} + {{:keys [chat-id]} :chat}] + (or (= app-state "background") + (not (chat.models/foreground-chat? cofx chat-id)))) (defn create-message-notification - ([cofx notification] - (when (or (nil? cofx) - (show-message-pn? cofx notification)) - (create-message-notification notification))) - ([{{:keys [message contact chat]} :body}] - (let [chat-type (get chat :chatType) - chat-id (get chat :id) - contact-name @(re-frame/subscribe - [:contacts/contact-name-by-identity (get contact :id)]) + ([{:keys [db] :as cofx} {{:keys [message]} :body :as notification}] + (when-not (nil? cofx) + (let [chat (chat-by-message db message) + contact-id (get message :from) + contact (get-in db [:contacts/contacts contact-id]) + notification (assoc notification + :chat chat + :contact-id contact-id + :contact contact)] + (when (show-message-pn? cofx notification) + (create-message-notification notification))))) + ([{{:keys [message]} :body + {:keys [chat-type chat-id] :as chat} :chat + {:keys [identicon]} :contact + contact-id :contact-id}] + (let [contact-name @(re-frame/subscribe + [:contacts/contact-name-by-identity contact-id]) group-chat? (not= chat-type constants/one-to-one-chat-type) title (clojure.string/join " " @@ -148,11 +155,11 @@ "#") (get chat :name)))))] {:type "message" - :chatType (str (get chat :chatType)) + :chatType (str chat-type) :from title :chatId chat-id :alias title - :identicon (get contact :identicon) + :identicon (or identicon (identicon/identicon contact-id)) :whisperTimestamp (get message :whisperTimestamp) :text (reply/get-quoted-text-with-mentions (:parsedText message))}))) diff --git a/status-go-version.json b/status-go-version.json index 2d324fb75d..a3cc6b31b5 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.71.5", - "commit-sha1": "da46a352925c105277f7d0953d077287d02c5c71", - "src-sha256": "041f9gvfpipanwwwwh395sv765ahvi1vx19hjw8p1qq4m59b4357" + "version": "v0.71.7", + "commit-sha1": "99a304686faadd465a90704b1e228f62ef873df2", + "src-sha256": "1wgwsh140bbha049adrr4jlaxzwmwd7n6a89r2wjpvdydfcpxpiv" }