Add sender name in PNs (if db is unlocked)

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-01-30 18:34:29 +01:00
parent fca51beaaa
commit 7366f8973b
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
11 changed files with 15 additions and 17 deletions

View File

@ -1,5 +1,5 @@
{:paths ["components/src" "src" "react-native/src/cljsjs" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.9.0"}
:deps {org.clojure/clojure {:mvn/version "1.9.0"} ;; Keep in sync with .TOOLVERSIONS
org.clojure/clojurescript {:mvn/version "1.10.439"}
org.clojure/core.async {:mvn/version "0.4.474"}
reagent {:mvn/version "0.7.0"

View File

@ -79,11 +79,14 @@
(def group-id "im.status.ethereum.MESSAGE")
(def icon "ic_stat_status_notification")
(defn- hash->contact [hash-or-pubkey accounts]
(let [hash (anonymize-pubkey hash-or-pubkey)]
(->> accounts
(filter #(= (anonymize-pubkey (:public-key %)) hash))
first)))
(defn- hash->pubkey [hash accounts]
(:public-key
(first
(filter #(= (anonymize-pubkey (:public-key %)) hash)
accounts))))
(:public-key (hash->contact hash accounts)))
(defn lookup-contact-pubkey-from-hash
[{:keys [db] :as cofx} contact-pubkey-or-hash]
@ -94,7 +97,7 @@
(= (count contact-pubkey-or-hash) pn-pubkey-hash-length))
(if-let
[account-pubkey (hash->pubkey contact-pubkey-or-hash
(vals (:accounts/accounts db)))]
(-> db :accounts/accounts vals))]
account-pubkey
(if (accounts.db/logged-in? cofx)
;; TODO: for simplicity we're doing a linear lookup of the contacts,
@ -144,6 +147,11 @@
;; TODO: Rehydrate message id
:id id})
(defn- get-contact-name [{:keys [db] :as cofx} from]
(if (accounts.db/logged-in? cofx)
(:name (hash->contact from (-> db :contacts/contacts vals)))
(anonymize-pubkey from)))
(defn- build-notification [{:keys [title body decoded-payload]}]
(let [native-notification
(clj->js
@ -226,7 +234,7 @@
(assoc-in db [:push-notifications/stored (:to rehydrated-payload)]
(js/JSON.stringify (clj->js rehydrated-payload)))
:notifications/display-notification
{:title (i18n/label :notifications-new-message-title)
{:title (get-contact-name cofx from)
:body (i18n/label :notifications-new-message-body)
:decoded-payload rehydrated-payload}})))

View File

@ -450,7 +450,6 @@
"other": "days"
},
"request-transaction": "Request transaction",
"notifications-new-message-title": "Status",
"wallet-send": "Send",
"wallet-deposit": "Deposit",
"invalid-key-title": "We detected a problem with the encryption key",
@ -742,7 +741,6 @@
"view-profile": "View profile",
"message": "Message",
"here-is-your-passphrase": "Here is your passphrase, *write this down and keep this safe!* You will need it to recover your account.",
"add-mailserver": "Add Mailserver",
"currency-display-name-ttd": "Trinidad and Tobago Dollar",
"wallet-assets": "Assets",
"are-you-sure-description": "You will not be able to see the whole recovery phrase again",

View File

@ -422,7 +422,6 @@
"not-specified": "No especificado",
"notifications": "Notificaciones",
"notifications-new-message-body": "Tienes un nuevo mensaje",
"notifications-new-message-title": "Status",
"notifications-title": "Notificaciones y sonidos",
"off": "Apagado",
"offline": "Desconectado",

View File

@ -423,7 +423,6 @@
"not-specified": "مشخص نشده",
"notifications": "اغلان ها",
"notifications-new-message-body": "شما یک پیغام جدید دارید",
"notifications-new-message-title": "استتوس",
"notifications-title": "اطلاعیه ها و صداها",
"off": "خاموش",
"offline": "آفلاین",

View File

@ -450,7 +450,6 @@
"not-specified": "지정되지 않음",
"notifications": "알림",
"notifications-new-message-body": "새로운 메세지가 있습니다",
"notifications-new-message-title": "스테이터스",
"notifications-title": "알림 및 소리",
"off": "끄기",
"offline": "오프라인",

View File

@ -450,7 +450,6 @@
"not-specified": "Tidak diberikan",
"notifications": "Pemberitahuan",
"notifications-new-message-body": "Anda mempunyai mesej baru",
"notifications-new-message-title": "Status",
"notifications-title": "Pemberitahuan dan bunyi",
"off": "Tidak aktif",
"offline": "Luar talian",

View File

@ -433,7 +433,6 @@
"not-specified": "नतोकिएको",
"notifications": "Pemberitahuan",
"notifications-new-message-body": "Anda mempunyai mesej baru",
"notifications-new-message-title": "Status",
"notifications-title": "सूचना र ध्वनि",
"off": "Tidak aktif",
"offline": "अफलाइन",

View File

@ -415,7 +415,6 @@
"not-specified": "Nie określono",
"notifications": "Powiadomienia",
"notifications-new-message-body": "Masz nową wiadomość",
"notifications-new-message-title": "Status",
"notifications-title": "Powiadomienia i dźwięki",
"off": "Wył.",
"offline": "Offline",

View File

@ -432,7 +432,6 @@
"not-specified": "Не указано",
"notifications": "Уведомления",
"notifications-new-message-body": "Вы получили новое сообщение",
"notifications-new-message-title": "Status",
"notifications-title": "Уведомления и звуки",
"off": "Выкл",
"offline": "Оффлайн",

View File

@ -450,7 +450,6 @@
"not-specified": "未指定",
"notifications": "通知",
"notifications-new-message-body": "你有新信息",
"notifications-new-message-title": "Status",
"notifications-title": "通知和声音",
"off": "关闭",
"offline": "离线",