[fix] add public-key when adding contact

Previously the public-key wasn't added when a contact was added until
a contact-request-confirmation was received. This was causing contact-update
not to be sent to contacts whose confirmation was not received yet when user
was updating his profile.

Signed-off-by: Eric Dvorsak <eric@dvorsak.fr>
This commit is contained in:
Eric Dvorsak 2018-05-14 20:13:42 +02:00
parent 98ee9d8fe4
commit 4f6eeea3b5
No known key found for this signature in database
GPG Key ID: 932AC1CE5F05DE0C
2 changed files with 7 additions and 8 deletions

View File

@ -19,8 +19,7 @@
:fcm-token fcm-token
:pending? true}
chat-props {:name name
:chat-id public-key
:contact-info (prn-str contact-props)}]
:chat-id public-key}]
(handlers-macro/merge-fx cofx
{:db (update-in db [:contacts/contacts public-key]
merge contact-props)

View File

@ -35,7 +35,9 @@
{:db (update db :contacts/contacts #(merge contacts %))})))
(defn- add-new-contact [{:keys [whisper-identity] :as contact} {:keys [db]}]
(let [new-contact (assoc contact :pending? false)]
(let [new-contact (assoc contact
:pending? false
:public-key whisper-identity)]
{:db (-> db
(update-in [:contacts/contacts whisper-identity]
merge new-contact)
@ -57,11 +59,9 @@
(transport/send (message.v1.contact/map->ContactRequest (own-info db)) whisper-identity cofx))))
(defn- build-contact [whisper-id {{:keys [chats] :contacts/keys [contacts]} :db}]
(-> (if-let [contact-info (get-in chats [whisper-id :contact-info])]
(reader/read-string contact-info)
(or (get contacts whisper-id)
(utils.contacts/whisper-id->new-contact whisper-id)))
(assoc :address (utils.contacts/public-key->address whisper-id))))
(assoc (or (get contacts whisper-id)
(utils.contacts/whisper-id->new-contact whisper-id))
:address (utils.contacts/public-key->address whisper-id)))
(defn add-contact [whisper-id {:keys [db] :as cofx}]
(let [contact (build-contact whisper-id cofx)]