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
|
||||
params []}} method-options
|
||||
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)
|
||||
(log/error :json-rpc/method-not-found method)
|
||||
(status/call-private-rpc
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
(:require
|
||||
[taoensso.timbre :as log]
|
||||
[re-frame.core :as re-frame]
|
||||
[clojure.string :as string]
|
||||
[status-im.contact.db :as contact.db]
|
||||
[status-im.data-store.multiaccounts :as data-store.multiaccounts]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
|
@ -13,6 +14,9 @@
|
|||
[status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[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]
|
||||
(json-rpc/call {:method "shhext_loadFilters"
|
||||
:params [chats]
|
||||
|
@ -160,9 +164,11 @@
|
|||
public?]}]
|
||||
(cond
|
||||
(not group-chat)
|
||||
[{:ChatID chat-id
|
||||
:OneToOne true
|
||||
:Identity (subs chat-id 2)}]
|
||||
;; Some legacy one-to-one chats (bots), have not a public key for id, we exclude those
|
||||
(when (is-public-key? chat-id)
|
||||
[{:ChatID chat-id
|
||||
:OneToOne true
|
||||
:Identity (subs chat-id 2)}])
|
||||
public?
|
||||
[{:ChatID chat-id
|
||||
:OneToOne false}]
|
||||
|
|
|
@ -62,6 +62,11 @@
|
|||
(transport.filters/chats->filter-requests [{:is-active true
|
||||
:group-chat false
|
||||
: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"
|
||||
(is (= [{:ChatID "chat-id"
|
||||
:OneToOne false}]
|
||||
|
|
Loading…
Reference in New Issue