Move mailserver logic to status-go

598b83757c...d60a6713fe
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2022-01-31 10:37:59 +00:00
parent c69b640810
commit 60cfca1107
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
13 changed files with 141 additions and 410 deletions

View File

@ -10,13 +10,6 @@ make shell TARGET=android
```
This step will take a while the first time as it will download all dependencies.
To build the app, your can simply run on of the following:
```
make release-android
make release-ios
```
For more `make` targets run `make help`.
# Development
There are three steps necessary to start development, in this case for Android:
@ -28,6 +21,18 @@ There are three steps necessary to start development, in this case for Android:
The first two will continue watching for changes and keep re-building the app. They need to be ready first.
The last one will exit once the app is up and ready.
You need to have your emulator or real devices running and visible to adb, before you run `make run-android`.
# Build release
To build the app, your can simply run on of the following:
```
make release-android
make release-ios
```
For more `make` targets run `make help`.
# Updating Dependencies
* `make nix-update-pods` - iOS CocoaPods dependencies (updates `ios/Podfile` and `ios/Podfile.loc`)

View File

@ -169,8 +169,7 @@
(fx/defn update-message-status
[{:keys [db] :as cofx} chat-id message-id status]
(fx/merge cofx
(update-db-message-status chat-id message-id status)
(data-store.messages/update-outgoing-status message-id status)))
(update-db-message-status chat-id message-id status)))
(fx/defn resend-message
[{:keys [db] :as cofx} chat-id message-id]

View File

@ -49,12 +49,6 @@
:outgoing (boolean (:outgoingStatus message)))
(dissoc :ensName :chatId :text :rtl :responseTo :image :sticker :lineCount :parsedText :links)))
(defn update-outgoing-status-rpc [message-id status]
{::json-rpc/call [{:method (json-rpc/call-ext-method "updateMessageOutgoingStatus")
:params [message-id status]
:on-success #(log/debug "updated message outgoing stauts" message-id status)
:on-failure #(log/error "failed to update message outgoing status" message-id status %)}]})
(defn messages-by-chat-id-rpc [chat-id
cursor
limit
@ -101,8 +95,5 @@
(fx/defn mark-messages-seen [cofx chat-id ids on-success]
(mark-seen-rpc chat-id ids on-success))
(fx/defn update-outgoing-status [cofx message-id status]
(update-outgoing-status-rpc message-id status))
(fx/defn delete-messages-by-chat-id [cofx chat-id]
(delete-messages-by-chat-id-rpc chat-id))

View File

@ -46,7 +46,8 @@
"waku_getSymKey" {}
"waku_markTrustedPeer" {}
"wakuext_post" {}
"wakuext_requestAllHistoricMessages" {}
"wakuext_requestAllHistoricMessagesWithRetries" {}
"wakuext_toggleUseMailservers" {}
"wakuext_editMessage" {}
"wakuext_deleteMessageAndSend" {}
"wakuext_fillGaps" {}
@ -93,7 +94,6 @@
"wakuext_markAllRead" {}
"wakuext_markAllReadInCommunity" {}
"wakuext_confirmMessagesProcessedByID" {}
"wakuext_updateMessageOutgoingStatus" {}
"wakuext_chatMessages" {}
"wakuext_saveChat" {}
"wakuext_muteChat" {}
@ -108,6 +108,7 @@
"wakuext_addContact" {}
"wakuext_updateMailservers" {}
"wakuext_sendEmojiReaction" {}
"wakuext_disconnectActiveMailserver" {}
"wakuext_sendEmojiReactionRetraction" {}
"wakuext_emojiReactionsByChatID" {}
"wakuext_getLinkPreviewWhitelist" {}
@ -115,6 +116,7 @@
"wakuext_requestCommunityInfoFromMailserver" {}
"wakuext_deactivateChat" {}
"wakuext_sendPinMessage" {}
"wakuext_setPinnedMailservers" {}
"wakuext_chatPinnedMessages" {}
;;TODO not used anywhere?
"wakuext_deleteChat" {}

View File

@ -4,15 +4,11 @@
[re-frame.core :as re-frame]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.i18n.i18n :as i18n]
[status-im.mailserver.constants :as constants]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.native-module.core :as status]
[status-im.node.core :as node]
[status-im.utils.mobile-sync :as mobile-network-utils]
[status-im.navigation :as navigation]
[status-im.utils.config :as config]
[status-im.utils.fx :as fx]
[status-im.utils.handlers :as handlers]
[taoensso.timbre :as log]))
;; How do mailserver work ?
@ -31,14 +27,6 @@
(defn connected? [db id]
(= (:mailserver/current-id db) id))
(def whisper-opts
{;; time drift that is tolerated by whisper, in seconds
:whisper-drift-tolerance 10
;; ttl of 10 sec
:ttl 10
:powTarget config/pow-target
:powTime config/pow-time})
(defn fetch [db id]
(get-in db [:mailserver/mailservers (node/current-fleet-key db) id]))
@ -60,127 +48,45 @@
current-fleet
vals)))))
(defn get-selected-mailserver
"Use the preferred mailserver if set & exists"
[db]
(let [preference (preferred-mailserver-id db)]
(when (and preference
(fetch db preference))
preference)))
;; We now wait for a confirmation from the mailserver before marking the message
;; as sent.
(defn update-mailservers! [enodes on-success]
(json-rpc/call
{:method (json-rpc/call-ext-method "updateMailservers")
:params [enodes]
:on-success #(do
(log/debug "mailserver: update-mailservers success" %)
(when on-success
(on-success)))
:on-error #(log/error "mailserver: update-mailservers error" %)}))
(defn remove-peer! [enode]
(let [args {:jsonrpc "2.0"
:id 2
:method "admin_removePeer"
:params [enode]}
payload (.stringify js/JSON (clj->js args))]
(when enode
(status/call-private-rpc payload
(handlers/response-handler
#(log/info "mailserver: remove-peer success" %)
#(log/error "mailserver: remove-peer error" %))))))
(re-frame/reg-fx
:mailserver/remove-peer
(fn [enode]
(remove-peer! enode)))
(re-frame/reg-fx
:mailserver/update-mailservers
(fn [[enodes on-success]]
(update-mailservers! enodes on-success)))
(defn registered-peer?
"truthy if the enode is a registered peer"
[peers enode]
(let [registered-enodes (into #{} (map :enode) peers)]
(contains? registered-enodes enode)))
(defn update-mailserver-state [db state]
(assoc db :mailserver/state state))
(fx/defn add-peer
[{:keys [db now] :as cofx}]
(let [{:keys [address] :as mailserver}
(fetch-current db)]
{:db (assoc
(update-mailserver-state db :connecting)
:mailserver/last-connection-attempt now)
;; Any message sent before this takes effect will not be marked as sent
;; probably we should improve the UX so that is more transparent to the
;; user
:mailserver/update-mailservers [[address]]}))
(fx/defn disconnect-from-mailserver
{:events [::disconnect-from-mailserver]}
[{:keys [db] :as cofx}]
(let [{:keys [address]} (fetch-current db)
{:keys [peers-summary]} db]
{:db (dissoc db :mailserver/current-request :mailserver/fetching-gaps-in-progress)
:mailserver/remove-peer address}))
{:db (-> db
(assoc :mailserver/state nil)
(dissoc :mailserver/current-request :mailserver/fetching-gaps-in-progress))})
(defn fetch-use-mailservers? [{:keys [db]}]
(get-in db [:multiaccount :use-mailservers?]))
(defn pool-size [fleet-size]
(.ceil js/Math (/ fleet-size 4)))
(defonce showing-connection-error-popup? (atom false))
(fx/defn get-mailservers-latency
[{:keys [db] :as cofx}]
(let [current-fleet (node/current-fleet-key db)
addresses (mapv :address (-> db
:mailserver/mailservers
current-fleet
vals))]
{::json-rpc/call [{:method "mailservers_ping"
:params [{:addresses addresses
:timeoutMs 500}]
:on-success
#(re-frame/dispatch [::get-latency-callback %])}]}))
(defn cancel-connection-popup! []
(reset! showing-connection-error-popup? false)
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true]))
(fx/defn log-mailserver-failure [{:keys [db now]}]
(when-let [mailserver (fetch-current db)]
{:db (assoc-in db [:mailserver/failures (:address mailserver)] now)}))
(re-frame/reg-fx
::cancel-connection-popup
cancel-connection-popup!)
(defn sort-mailservers
"Sort mailservers sorts the mailservers by recent failures, and by rtt
for breaking ties"
[{:keys [now db]} mailservers]
(let [mailserver-failures (:mailserver/failures db)
sort-fn (fn [a b]
(let [failures-a (get mailserver-failures (:address a))
failures-b (get mailserver-failures (:address b))
has-a-failed? (boolean
(and failures-a (<= (- now failures-a) constants/cooloff-period)))
has-b-failed? (boolean
(and failures-b (<= (- now failures-b) constants/cooloff-period)))]
;; If both have failed, or none of them, then compare rtt
(cond
(= has-a-failed? has-b-failed?)
(compare (:rttMs a) (:rttMs b))
;; Otherwise prefer the one that has not failed recently
has-a-failed? 1
has-b-failed? -1)))]
(sort sort-fn mailservers)))
(defn get-mailserver-when-ready
"return the mailserver if the mailserver is ready"
[{:keys [db]}]
(let [mailserver (fetch-current db)
mailserver-state (:mailserver/state db)]
(when (= :connected mailserver-state)
mailserver)))
(fx/defn show-connection-error! [cofx current-fleet preferred-mailserver]
(reset! showing-connection-error-popup? true)
{:ui/show-confirmation
{:title (i18n/label :t/mailserver-error-title)
:content (i18n/label :t/mailserver-error-content)
:confirm-button-text (i18n/label :t/mailserver-pick-another)
:on-cancel cancel-connection-popup!
:on-accept #(do
(reset! showing-connection-error-popup? false)
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true])
(re-frame/dispatch [:navigate-to :offline-messaging-settings]))
:extra-options [{:text (i18n/label :t/mailserver-retry)
:onPress #(do
(reset! showing-connection-error-popup? false)
(re-frame/dispatch
[:mailserver.ui/connect-confirmed
current-fleet
preferred-mailserver]))
:style "default"}]}})
(fx/defn handle-successful-request
{:events [::request-success]}
@ -188,6 +94,20 @@
{:db (dissoc db :mailserver/current-request)
:dispatch [:sanitize-messages-and-process-response response-js]})
(fx/defn handle-mailserver-not-working [{:keys [db] :as cofx}]
(let [current-fleet (node/current-fleet-key db)
error-dismissed? (connection-error-dismissed db)
pinned-mailserver (get-in db [:multiaccount :pinned-mailservers current-fleet])]
(when (and pinned-mailserver
(not error-dismissed?)
(not @showing-connection-error-popup?))
(show-connection-error! cofx current-fleet pinned-mailserver))))
(fx/defn handle-request-error
{:events [::request-error]}
[{:keys [db] :as cofx}]
{:db (dissoc db :mailserver/current-request)})
(fx/defn process-next-messages-request
{:events [::request-messages]}
[{:keys [db now] :as cofx}]
@ -196,95 +116,36 @@
(mobile-network-utils/syncing-allowed? cofx)
(fetch-use-mailservers? cofx)
(not (:mailserver/current-request db)))
(when-let [mailserver (get-mailserver-when-ready cofx)]
{:db (assoc db :mailserver/current-request true)
::json-rpc/call [{:method "wakuext_requestAllHistoricMessages"
:params []
:js-response true
:on-success #(do
(log/info "fetched historical messages")
(re-frame/dispatch [::request-success %]))
:on-failure #(log/error "failed retrieve historical messages" %)}]})))
{:db (assoc db :mailserver/current-request true)
::json-rpc/call [{:method "wakuext_requestAllHistoricMessagesWithRetries"
:params []
:js-response true
:on-success #(do
(log/info "fetched historical messages")
(re-frame/dispatch [::request-success %]))
:on-error #(do
(log/error "failed retrieve historical messages" %)
(re-frame/dispatch [::request-error]))}]}))
(fx/defn handle-mailserver-changed
[{:keys [db] :as cofx} ms]
(if (seq ms)
{:db (assoc db :mailserver/state :connecting
:mailserver/current-id (keyword ms))}
{:db (assoc db :mailserver/state nil)}))
(fx/defn handle-mailserver-available
[{:keys [db] :as cofx} ms]
{::cancel-connection-popup []
:db (assoc db :mailserver/state :connected
:mailserver/current-id (keyword ms))})
(fx/defn connected-to-mailserver
[{:keys [db] :as cofx}]
(let [{:keys [address]} (fetch-current db)]
(fx/merge
cofx
{:db (update-mailserver-state db :connected)
:mailserver/update-mailservers [[address] #(re-frame/dispatch [::request-messages])]})))
(fx/defn connect-to-mailserver
"Add mailserver as a peer using `::add-peer` cofx and generate sym-key when
it doesn't exists
Peer summary will change and we will receive a signal from status go when
this is successful
A connection-check is made after `connection timeout` is reached and
mailserver-state is changed to error if it is not connected by then
No attempt is made if mailserver usage is disabled"
{:events [:mailserver.ui/reconnect-mailserver-pressed]}
[{:keys [db] :as cofx}]
(let [{:keys [address]} (fetch-current db)
{:keys [peers-summary]} db
use-mailservers? (fetch-use-mailservers? cofx)
added? (registered-peer? peers-summary address)]
(when use-mailservers?
(fx/merge cofx
{:db (dissoc db :mailserver/current-request)}
(if added?
(connected-to-mailserver)
(add-peer))))))
(fx/defn set-current-mailserver-with-lowest-latency
"Picks a random mailserver amongs the ones with the lowest latency
The results with error are ignored
The pool size is 1/4 of the mailservers were pinged successfully"
{:events [::get-latency-callback]}
[{:keys [db] :as cofx} latency-results]
(let [successful-pings (remove :error latency-results)]
(when (seq successful-pings)
(let [address (-> (take (pool-size (count successful-pings))
(sort-mailservers cofx successful-pings))
rand-nth
:address)
mailserver-id (mailserver-address->id db address)]
(fx/merge cofx
{:db (assoc db :mailserver/current-id mailserver-id)}
(connect-to-mailserver))))))
(fx/defn set-current-mailserver
[{:keys [db] :as cofx}]
(if-let [mailserver-id (get-selected-mailserver db)]
(fx/merge cofx
{:db (assoc db :mailserver/current-id mailserver-id)}
(connect-to-mailserver))
(get-mailservers-latency cofx)))
(fx/defn peers-summary-change
"There is only 2 summary changes that require mailserver action:
- mailserver disconnected: we try to reconnect
- mailserver connected: we mark the mailserver as trusted peer"
[{:keys [db] :as cofx} previous-summary]
(when (:multiaccount db)
(if (:mailserver/current-id db)
(let [{:keys [peers-summary peers-count]} db
{:keys [address] :as mailserver} (fetch-current db)
mailserver-was-registered? (registered-peer? previous-summary
address)
mailserver-is-registered? (registered-peer? peers-summary
address)
mailserver-added? (and mailserver-is-registered?
(not mailserver-was-registered?))
mailserver-removed? (and mailserver-was-registered?
(not mailserver-is-registered?))]
(cond
mailserver-added?
(connected-to-mailserver cofx)
mailserver-removed?
(connect-to-mailserver cofx)))
;; if there is no current mailserver defined
;; we set it first
(set-current-mailserver cofx))))
{:mailserver/update-mailservers [[address] #(re-frame/dispatch [::request-messages])]})))
(fx/defn handle-request-success
{:events [:mailserver.callback/request-success]}
@ -293,87 +154,23 @@
{:db (assoc-in db [:mailserver/current-request :request-id]
request-id)}))
(fx/defn toggle-use-mailservers
[cofx value]
{::json-rpc/call
[{:method "wakuext_toggleUseMailservers"
:params [value]
:on-success #(log/info "successfully toggled use-mailservers" value)
:on-failure #(log/error "failed to toggle use-mailserver" value %)}]})
(fx/defn update-use-mailservers
{:events [:mailserver.ui/use-history-switch-pressed]}
[cofx use-mailservers?]
(fx/merge cofx
(multiaccounts.update/multiaccount-update :use-mailservers? use-mailservers? {})
(if use-mailservers?
(connect-to-mailserver)
(multiaccounts.update/optimistic :use-mailservers? use-mailservers?)
(toggle-use-mailservers use-mailservers?)
(when use-mailservers?
(disconnect-from-mailserver))))
(defonce showing-connection-error-popup? (atom false))
(defn show-connection-error! [db current-fleet preferred-mailserver]
(reset! showing-connection-error-popup? true)
(assoc db :ui/show-confirmation
{:title (i18n/label :t/mailserver-error-title)
:content (i18n/label :t/mailserver-error-content)
:confirm-button-text (i18n/label :t/mailserver-pick-another)
:on-cancel #(do
(reset! showing-connection-error-popup? false)
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true]))
:on-accept #(do
(reset! showing-connection-error-popup? false)
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true])
(re-frame/dispatch [:navigate-to :offline-messaging-settings]))
:extra-options [{:text (i18n/label :t/mailserver-retry)
:onPress #(do
(reset! showing-connection-error-popup? false)
(re-frame/dispatch
[:mailserver.ui/connect-confirmed
current-fleet
preferred-mailserver]))
:style "default"}]}))
(fx/defn change-mailserver
"mark mailserver status as `:error` if custom mailserver is used
otherwise try to reconnect to another mailserver"
[{:keys [db] :as cofx}]
(when (and (fetch-use-mailservers? cofx)
;; For some reason the tests are checking
;; for non-zero, so nil value is ok, not
;; sure is intentional, but will leave it as it is
;; instead of using pos?
(not (zero? (:peers-count db))))
(if-let [preferred-mailserver (preferred-mailserver-id db)]
(let [error-dismissed? (connection-error-dismissed db)
current-fleet (node/current-fleet-key db)]
;; Error connecting to the mail server
(cond-> {:db (update-mailserver-state db :error)}
(not (or error-dismissed? @showing-connection-error-popup?))
(show-connection-error! current-fleet preferred-mailserver)))
(let [{:keys [address]} (fetch-current db)]
(fx/merge cofx
{:mailserver/remove-peer address}
(set-current-mailserver))))))
(defn check-connection! []
(re-frame/dispatch [:mailserver/check-connection-timeout]))
(fx/defn check-connection
"Check connection checks that the connection is successfully connected,
otherwise it will try to change mailserver and connect again"
{:events [:mailserver/check-connection-timeout]}
[{:keys [db now] :as cofx}]
;; check if logged into multiaccount
(when (contains? db :multiaccount)
(let [last-connection-attempt (:mailserver/last-connection-attempt db)]
(if (and (fetch-use-mailservers? cofx)
;; We are not connected
(not= :connected (:mailserver/state db))
;; We either never tried to connect to this peer
(or (nil? last-connection-attempt)
;; Or 30 seconds have passed and no luck
(>= (- now last-connection-attempt) (* constants/connection-timeout 3))))
;; Then we change mailserver
(change-mailserver cofx)
;; Just make sure it's set
(let [{:keys [address] :as mailserver}
(fetch-current db)]
(when address
{:mailserver/update-mailservers [[address]]}))))))
(fx/defn retry-next-messages-request
{:events [:mailserver.ui/retry-request-pressed]}
[{:keys [db] :as cofx}]
@ -381,15 +178,6 @@
{:db (dissoc db :mailserver/request-error)}
(process-next-messages-request)))
;; At some point we should update `last-request`, as eventually we want to move
;; on, rather then keep asking for the same data, say after n amounts of attempts
(fx/defn handle-request-error
[{:keys [db]} error]
{:db (-> db
(assoc :mailserver/request-error error)
(dissoc :mailserver/current-request
:mailserver/pending-requests))})
(fx/defn show-request-error-popup
{:events [:mailserver.ui/request-error-pressed]}
[{:keys [db]}]
@ -401,13 +189,6 @@
:on-accept #(re-frame/dispatch [:mailserver.ui/retry-request-pressed])
:confirm-button-text (i18n/label :t/mailserver-request-retry)}}))
(fx/defn initialize-mailserver
[{:keys [db] :as cofx}]
(fx/merge cofx
{:db db}
(set-current-mailserver)
(process-next-messages-request)))
(def enode-address-regex
#"enode://[a-zA-Z0-9]+\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")
(def enode-url-regex
@ -448,7 +229,7 @@
(cond-> {:address (if (seq response)
(str "enode://" enode "@" url)
address)
:user-defined true}
:custom true}
password (assoc :password password))))
(defn- build [id mailserver-name address]
@ -456,10 +237,10 @@
:id id
:name mailserver-name))
(def default? (comp not :user-defined fetch))
(def default? (comp not :custom fetch))
(fx/defn edit
{:events [:mailserver.ui/user-defined-mailserver-selected]}
{:events [:mailserver.ui/custom-mailserver-selected]}
[{:keys [db] :as cofx} id]
(let [{:keys [id address password name]} (fetch db id)
url (when address (build-url address password))]
@ -568,37 +349,35 @@
[{:keys [db]} new-state]
{:db (assoc db :mailserver/connection-error-dismissed new-state)})
(fx/defn save-settings
(fx/defn pin-mailserver
{:events [:mailserver.ui/connect-confirmed]}
[{:keys [db] :as cofx} current-fleet mailserver-id]
(let [{:keys [address]} (fetch-current db)
pinned-mailservers (get-in db [:multiaccount :pinned-mailservers])
;; Check if previous mailserver was pinned
pinned? (get pinned-mailservers current-fleet)
use-mailservers? (fetch-use-mailservers? cofx)]
(let [pinned-mailservers (-> db
(get-in [:multiaccount :pinned-mailservers])
(assoc current-fleet mailserver-id))]
(fx/merge cofx
{:db (assoc db :mailserver/current-id mailserver-id)
:mailserver/remove-peer address}
(when use-mailservers? (connect-to-mailserver))
(dismiss-connection-error false)
(when pinned?
(multiaccounts.update/multiaccount-update
:pinned-mailservers (assoc pinned-mailservers
current-fleet
mailserver-id)
{})))))
::json-rpc/call [{:method "wakuext_setPinnedMailservers"
:params [pinned-mailservers]
:on-success #(log/info "successfully pinned mailserver")
:on-error #(log/error "failed to pin mailserver" %)}]}
(multiaccounts.update/optimistic :pinned-mailservers pinned-mailservers))))
(fx/defn unpin
{:events [:mailserver.ui/unpin-pressed]}
[{:keys [db] :as cofx}]
(let [current-fleet (node/current-fleet-key db)
pinned-mailservers (get-in db [:multiaccount :pinned-mailservers])]
pinned-mailservers (-> db
(get-in [:multiaccount :pinned-mailservers])
(dissoc current-fleet))]
(fx/merge cofx
(multiaccounts.update/multiaccount-update
:pinned-mailservers (dissoc pinned-mailservers current-fleet)
{})
(dismiss-connection-error false)
(change-mailserver))))
{::json-rpc/call [{:method "wakuext_setPinnedMailservers"
:params [pinned-mailservers]
:on-success #(log/info "successfully unpinned mailserver")
:on-error #(log/error "failed to unpin mailserver" %)}]}
(multiaccounts.update/optimistic
:pinned-mailservers pinned-mailservers)
(dismiss-connection-error false))))
(fx/defn pin
{:events [:mailserver.ui/pin-pressed]}

View File

@ -4,7 +4,6 @@
[status-im.i18n.i18n :as i18n]
[status-im.init.core :as init]
[status-im.native-module.core :as status]
[status-im.transport.core :as transport]
[status-im.utils.fx :as fx]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.utils.keychain.core :as keychain]
@ -26,7 +25,6 @@
(when should-send-metrics?
(anon-metrics/stop-transferring))
(keychain/save-auth-method key-uid auth-method)
(transport/stop-whisper)
(wallet/clear-timeouts)
(init/initialize-app-db))))

View File

@ -42,7 +42,6 @@
{:db (assoc db
:peers-summary peers-summary
:peers-count peers-count)}
(mailserver/peers-summary-change previous-summary)
(visibility-status-updates/peers-summary-change peers-count))))
(fx/defn wakuv2-peer-stats
@ -67,6 +66,9 @@
"envelope.expired" (transport.message/update-envelopes-status cofx (:ids (js->clj event-js :keywordize-keys true)) :not-sent)
"message.delivered" (let [{:keys [chatID messageID]} (js->clj event-js :keywordize-keys true)]
(models.message/update-db-message-status cofx chatID messageID :delivered))
"mailserver.changed" (mailserver/handle-mailserver-changed cofx (.-id event-js))
"mailserver.available" (mailserver/handle-mailserver-available cofx (.-id event-js))
"mailserver.not.working" (mailserver/handle-mailserver-not-working cofx)
"discovery.summary" (summary cofx (js->clj event-js :keywordize-keys true))
"wakuv2.peerstats" (wakuv2-peer-stats cofx (js->clj event-js :keywordize-keys true))
"subscriptions.data" (ethereum.subscriptions/handle-signal cofx (js->clj event-js :keywordize-keys true))

View File

@ -2955,4 +2955,4 @@
:bookmarks/active
:<- [:bookmarks]
(fn [bookmarks]
(into {} (remove #(:removed (second %)) bookmarks))))
(into {} (remove #(:removed (second %)) bookmarks))))

View File

@ -2,12 +2,10 @@
status-im.transport.core
(:require [re-frame.core :as re-frame]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.mailserver.core :as mailserver]
[status-im.native-module.core :as status]
[status-im.pairing.core :as pairing]
[status-im.utils.fx :as fx]
[status-im.utils.handlers :as handlers]
[status-im.utils.publisher :as publisher]
status-im.transport.shh
[taoensso.timbre :as log]
[status-im.utils.universal-links.core :as universal-links]))
@ -34,19 +32,19 @@
(fx/defn fetch-node-info-fx [cofx]
{::fetch-node-info []})
(defn add-custom-mailservers
[db custom-mailservers]
(reduce (fn [db {:keys [fleet] :as mailserver}]
(let [{:keys [id] :as mailserver}
(defn add-mailservers
[db mailservers]
(reduce (fn [db {:keys [fleet id name] :as mailserver}]
(let [updated-mailserver
(-> mailserver
(update :id keyword)
(dissoc :fleet)
(assoc :user-defined true))]
(assoc :name (if (seq name) name id))
(dissoc :fleet))]
(assoc-in db
[:mailserver/mailservers (keyword fleet) id]
mailserver)))
[:mailserver/mailservers (keyword fleet) (keyword id)]
updated-mailserver)))
db
custom-mailservers))
mailservers))
(fx/defn start-messenger
"We should only start receiving messages/processing topics once all the
@ -64,14 +62,7 @@
(fx/merge cofx
{:db (-> db
(assoc :messenger/started? true)
(add-custom-mailservers mailservers))}
(add-mailservers mailservers))}
(fetch-node-info-fx)
(pairing/init)
(publisher/start-fx)
(mailserver/initialize-mailserver)
(universal-links/process-stored-event)))
(fx/defn stop-whisper
"Stops whisper protocol"
[cofx]
(publisher/stop-fx cofx))

View File

@ -155,7 +155,9 @@
(i18n/label :t/status-mobile-descr)]])]))
(defn get-icon [{:keys [peers node mobile sync]}]
(if (= peers :offline)
(if (or (= peers :offline)
(= node :offline)
(= node :connecting))
:main-icons/offline
(if mobile
(if sync :main-icons/mobile-sync :main-icons/mobile-sync-off)

View File

@ -24,7 +24,7 @@
[react/text {:style styles/explanation-text}
(i18n/label :t/mailserver-automatic-switch-explanation)]]])
(defn render-row [{:keys [name id user-defined]} _ _ {:keys [current-mailserver-id preferred-mailserver-id]}]
(defn render-row [{:keys [name id custom]} _ _ {:keys [current-mailserver-id preferred-mailserver-id]}]
(let [pinned? preferred-mailserver-id
connected? (= id current-mailserver-id)
visible? (or pinned? ; show everything when auto selection is turned off
@ -33,8 +33,8 @@
(when visible?
[react/touchable-highlight
{:on-press (when pinned? #(if user-defined
(re-frame/dispatch [:mailserver.ui/user-defined-mailserver-selected id])
{:on-press (when pinned? #(if custom
(re-frame/dispatch [:mailserver.ui/custom-mailserver-selected id])
(re-frame/dispatch [:mailserver.ui/default-mailserver-selected id])))
:accessibility-label :mailserver-item}
[react/view (styles/mailserver-item)

View File

@ -1,38 +0,0 @@
(ns status-im.utils.publisher
(:require [re-frame.core :as re-frame]
[re-frame.db]
[status-im.utils.async :as async-util]
[status-im.mailserver.core :as mailserver]
[status-im.utils.fx :as fx]))
(defonce polling-executor (atom nil))
(def sync-interval-ms 10000)
(def sync-timeout-ms 20000)
(defn- start-publisher! []
(when @polling-executor
(async-util/async-periodic-stop! @polling-executor))
(reset! polling-executor
(async-util/async-periodic-exec
(fn [done-fn]
(mailserver/check-connection!)
(done-fn))
sync-interval-ms
sync-timeout-ms)))
(re-frame/reg-fx
::start-publisher
start-publisher!)
(re-frame/reg-fx
::stop-publisher
#(when @polling-executor
(async-util/async-periodic-stop! @polling-executor)))
(fx/defn start-fx
[_]
{::start-publisher nil})
(fx/defn stop-fx
[_]
{::stop-publisher []})

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.94.10",
"commit-sha1": "598b83757cc8b27e3374e50de02187eacf0d4280",
"src-sha256": "0ncywjmpng7zdx707j45yxzj0m06c24mi0lgk3d2yzbp7gx3cygz"
"version": "v0.96.0",
"commit-sha1": "d60a6713fe2a0ed0fdf03a0777a8cfa7391d7c56",
"src-sha256": "19jzac10xwl8hpls45ph56f4gqyydwg3rdqmvm25fmp8ggjwvr1m"
}