diff --git a/src/status_im/transport/inbox.cljs b/src/status_im/transport/inbox.cljs index ea63f30fc6..6c82065f35 100644 --- a/src/status_im/transport/inbox.cljs +++ b/src/status_im/transport/inbox.cljs @@ -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 diff --git a/src/status_im/transport/message/v1/public_chat.cljs b/src/status_im/transport/message/v1/public_chat.cljs index e417bd0c7a..51560e75cc 100644 --- a/src/status_im/transport/message/v1/public_chat.cljs +++ b/src/status_im/transport/message/v1/public_chat.cljs @@ -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 diff --git a/src/status_im/transport/shh.cljs b/src/status_im/transport/shh.cljs index 12f14a5ba9..57c68978db 100644 --- a/src/status_im/transport/shh.cljs +++ b/src/status_im/transport/shh.cljs @@ -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})))) diff --git a/src/status_im/utils/handlers_macro.cljs b/src/status_im/utils/handlers_macro.cljs index c6ddcde11d..f6998a283e 100644 --- a/src/status_im/utils/handlers_macro.cljs +++ b/src/status_im/utils/handlers_macro.cljs @@ -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) diff --git a/test/cljs/status_im/test/transport/inbox.cljs b/test/cljs/status_im/test/transport/inbox.cljs index ca78f456c2..1fdfc47ab8 100644 --- a/test/cljs/status_im/test/transport/inbox.cljs +++ b/test/cljs/status_im/test/transport/inbox.cljs @@ -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"