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:
Andrea Maria Piana 2019-07-30 19:07:16 +02:00
parent 7517f5235a
commit 1e655540da
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
3 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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)
;; 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)}]
:Identity (subs chat-id 2)}])
public?
[{:ChatID chat-id
:OneToOne false}]

View File

@ -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}]