mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-13 10:16:01 +00:00
[fix 5715] make generate-sym-key-from-password mergeable
Signed-off-by: Eric Dvorsak <eric@dvorsak.fr>
This commit is contained in:
parent
3513adb7ca
commit
02191f0380
@ -167,11 +167,11 @@
|
||||
(defn generate-mailserver-symkey [wnode {:keys [db] :as cofx}]
|
||||
(when-not (:sym-key-id wnode)
|
||||
{:shh/generate-sym-key-from-password
|
||||
{:password (:password wnode)
|
||||
:web3 (:web3 db)
|
||||
:on-success (fn [_ sym-key-id]
|
||||
(re-frame/dispatch [:inbox/get-sym-key-success wnode sym-key-id]))
|
||||
:on-error #(log/error "offline inbox: get-sym-key error" %)}}))
|
||||
[{:password (:password wnode)
|
||||
:web3 (:web3 db)
|
||||
:on-success (fn [_ sym-key-id]
|
||||
(re-frame/dispatch [:inbox/get-sym-key-success wnode sym-key-id]))
|
||||
:on-error #(log/error "offline inbox: get-sym-key error" %)}]}))
|
||||
|
||||
(defn connect-to-mailserver
|
||||
"Add mailserver as a peer using ::add-peer cofx and generate sym-key when
|
||||
|
@ -20,9 +20,9 @@
|
||||
:sym-key sym-key
|
||||
:sym-key-id sym-key-id}]))]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:shh/generate-sym-key-from-password {:web3 (:web3 db)
|
||||
:password chat-id
|
||||
:on-success on-success}}
|
||||
{:shh/generate-sym-key-from-password [{:web3 (:web3 db)
|
||||
:password chat-id
|
||||
:on-success on-success}]}
|
||||
(protocol/init-chat {:chat-id chat-id})))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
@ -162,13 +162,14 @@
|
||||
|
||||
(re-frame/reg-fx
|
||||
:shh/generate-sym-key-from-password
|
||||
(fn [{:keys [web3 password on-success]}]
|
||||
(generate-sym-key-from-password {:web3 web3
|
||||
:password password
|
||||
:on-success (fn [sym-key-id]
|
||||
(get-sym-key {:web3 web3
|
||||
:sym-key-id sym-key-id
|
||||
:on-success (fn [sym-key]
|
||||
(on-success sym-key sym-key-id))
|
||||
:on-error log-error}))
|
||||
:on-error log-error})))
|
||||
(fn [args]
|
||||
(doseq [{:keys [web3 password on-success]} args]
|
||||
(generate-sym-key-from-password {:web3 web3
|
||||
:password password
|
||||
:on-success (fn [sym-key-id]
|
||||
(get-sym-key {:web3 web3
|
||||
:sym-key-id sym-key-id
|
||||
:on-success (fn [sym-key]
|
||||
(on-success sym-key sym-key-id))
|
||||
:on-error log-error}))
|
||||
:on-error log-error}))))
|
||||
|
@ -11,7 +11,8 @@
|
||||
(def ^:private mergable-keys
|
||||
#{:data-store/tx :data-store/base-tx :chat-received-message/add-fx
|
||||
:shh/add-new-sym-keys :shh/get-new-sym-keys :shh/post
|
||||
:confirm-messages-processed :utils/dispatch-later})
|
||||
:shh/generate-sym-key-from-password :confirm-messages-processed
|
||||
:utils/dispatch-later})
|
||||
|
||||
(defn safe-merge [fx new-fx]
|
||||
(if (:merging-fx-with-common-keys fx)
|
||||
|
@ -60,13 +60,15 @@
|
||||
(is (= "wnode-password"
|
||||
(-> (inbox/connect-to-mailserver {:db db})
|
||||
:shh/generate-sym-key-from-password
|
||||
first
|
||||
:password))))
|
||||
(let [wnode-with-sym-key-db (assoc-in db
|
||||
[:inbox/wnodes :mainnet "wnodeid" :sym-key-id]
|
||||
"somesymkeyid")]
|
||||
(testing "it does not generate a sym key if already present"
|
||||
(is (not (-> (inbox/connect-to-mailserver {:db wnode-with-sym-key-db})
|
||||
:shh/generate-sym-key-from-password)))))))
|
||||
:shh/generate-sym-key-from-password
|
||||
first)))))))
|
||||
|
||||
(deftest request-messages
|
||||
(let [db {:network "mainnet"
|
||||
|
Loading…
x
Reference in New Issue
Block a user