Fix loading of filters
Currently on some devices there are still some legacy chats(?) that are one-to-one but don't have a public key as an id (transactor,demo-bot). We were wrongly sending those to status-go to create filters. Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
7517f5235a
commit
1e655540da
|
@ -52,7 +52,7 @@
|
||||||
id 1
|
id 1
|
||||||
params []}} method-options
|
params []}} method-options
|
||||||
on-error (or on-error
|
on-error (or on-error
|
||||||
#(log/warn :json-rpc/error method :params params :error %))]
|
#(log/warn :json-rpc/error method :error % :params params))]
|
||||||
(if (nil? method)
|
(if (nil? method)
|
||||||
(log/error :json-rpc/method-not-found method)
|
(log/error :json-rpc/method-not-found method)
|
||||||
(status/call-private-rpc
|
(status/call-private-rpc
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
(:require
|
(:require
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
|
[clojure.string :as string]
|
||||||
[status-im.contact.db :as contact.db]
|
[status-im.contact.db :as contact.db]
|
||||||
[status-im.data-store.multiaccounts :as data-store.multiaccounts]
|
[status-im.data-store.multiaccounts :as data-store.multiaccounts]
|
||||||
[status-im.ethereum.json-rpc :as json-rpc]
|
[status-im.ethereum.json-rpc :as json-rpc]
|
||||||
|
@ -13,6 +14,9 @@
|
||||||
[status-im.multiaccounts.model :as multiaccounts.model]
|
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||||
[status-im.transport.utils :as utils]))
|
[status-im.transport.utils :as utils]))
|
||||||
|
|
||||||
|
(defn is-public-key? [k]
|
||||||
|
(string/starts-with? k "0x"))
|
||||||
|
|
||||||
(defn load-filters-rpc [chats on-success on-failure]
|
(defn load-filters-rpc [chats on-success on-failure]
|
||||||
(json-rpc/call {:method "shhext_loadFilters"
|
(json-rpc/call {:method "shhext_loadFilters"
|
||||||
:params [chats]
|
:params [chats]
|
||||||
|
@ -160,9 +164,11 @@
|
||||||
public?]}]
|
public?]}]
|
||||||
(cond
|
(cond
|
||||||
(not group-chat)
|
(not group-chat)
|
||||||
[{:ChatID chat-id
|
;; Some legacy one-to-one chats (bots), have not a public key for id, we exclude those
|
||||||
:OneToOne true
|
(when (is-public-key? chat-id)
|
||||||
:Identity (subs chat-id 2)}]
|
[{:ChatID chat-id
|
||||||
|
:OneToOne true
|
||||||
|
:Identity (subs chat-id 2)}])
|
||||||
public?
|
public?
|
||||||
[{:ChatID chat-id
|
[{:ChatID chat-id
|
||||||
:OneToOne false}]
|
:OneToOne false}]
|
||||||
|
|
|
@ -62,6 +62,11 @@
|
||||||
(transport.filters/chats->filter-requests [{:is-active true
|
(transport.filters/chats->filter-requests [{:is-active true
|
||||||
:group-chat false
|
:group-chat false
|
||||||
:chat-id "0xchat-id"}]))))
|
:chat-id "0xchat-id"}]))))
|
||||||
|
(testing "a malformed one to one chat"
|
||||||
|
(is (= []
|
||||||
|
(transport.filters/chats->filter-requests [{:is-active true
|
||||||
|
:group-chat false
|
||||||
|
:chat-id "malformed"}]))))
|
||||||
(testing "a single public chat"
|
(testing "a single public chat"
|
||||||
(is (= [{:ChatID "chat-id"
|
(is (= [{:ChatID "chat-id"
|
||||||
:OneToOne false}]
|
:OneToOne false}]
|
||||||
|
|
Loading…
Reference in New Issue