Skip to content

Commit 97f8247

Browse files
flexsurferyevh-berdnyk
authored andcommitted
move transport (#18062)
1 parent 0307acd commit 97f8247

File tree

20 files changed

+217
-320
lines changed

20 files changed

+217
-320
lines changed

.carve_ignore

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ react-native.fs/unlink
9595
react-native.fs/file-exists?
9696
status-im.ui.components.colors/white
9797
status-im.ui.components.colors/black
98-
status-im.transport.core-test/messages
9998
status-im.ui.components.core/animated-header
10099
status-im.ui.components.core/safe-area-provider
101100
status-im.ui.components.core/safe-area-consumer

src/status_im/chat/models/input.cljs

+18-17
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
[goog.object :as object]
66
[re-frame.core :as re-frame]
77
[status-im.chat.models.mentions :as mentions]
8-
[status-im.chat.models.message :as chat.message]
98
[status-im.chat.models.message-content :as message-content]
109
[status-im.data-store.messages :as data-store-messages]
1110
[status-im2.constants :as constants]
1211
[status-im2.contexts.chat.composer.link-preview.events :as link-preview]
12+
[status-im2.contexts.chat.messages.transport.events :as messages.transport]
1313
[taoensso.timbre :as log]
1414
[utils.i18n :as i18n]
1515
[utils.re-frame :as rf]
@@ -205,7 +205,7 @@
205205
(rf/merge cofx
206206
(clean-input (:current-chat-id db))
207207
(link-preview/reset-unfurled)
208-
(chat.message/send-messages messages)))))
208+
(messages.transport/send-chat-messages messages)))))
209209

210210
(rf/defn send-audio-message
211211
[{:keys [db] :as cofx} audio-path duration current-chat-id]
@@ -214,25 +214,26 @@
214214
(when-not (string/blank? audio-path)
215215
(rf/merge
216216
{:db (assoc-in db [:chat/inputs current-chat-id :metadata :responding-to-message] nil)}
217-
(chat.message/send-message
218-
(merge
219-
{:chat-id current-chat-id
220-
:content-type constants/content-type-audio
221-
:audio-path audio-path
222-
:audio-duration-ms duration
223-
:text (i18n/label :t/update-to-listen-audio {"locale" "en"})}
224-
(when message-id
225-
{:response-to message-id})))))))
217+
(messages.transport/send-chat-messages
218+
[(merge
219+
{:chat-id current-chat-id
220+
:content-type constants/content-type-audio
221+
:audio-path audio-path
222+
:audio-duration-ms duration
223+
:text (i18n/label :t/update-to-listen-audio {"locale" "en"})}
224+
(when message-id
225+
{:response-to message-id}))])))))
226226

227227
(rf/defn send-sticker-message
228228
[cofx {:keys [hash packID pack]} current-chat-id]
229229
(when-not (or (string/blank? hash) (and (string/blank? packID) (string/blank? pack)))
230-
(chat.message/send-message cofx
231-
{:chat-id current-chat-id
232-
:content-type constants/content-type-sticker
233-
:sticker {:hash hash
234-
:pack (int (if (string/blank? packID) pack packID))}
235-
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})})))
230+
(messages.transport/send-chat-messages
231+
cofx
232+
[{:chat-id current-chat-id
233+
:content-type constants/content-type-sticker
234+
:sticker {:hash hash
235+
:pack (int (if (string/blank? packID) pack packID))}
236+
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})}])))
236237

237238
(rf/defn send-edited-message
238239
[{:keys [db]

src/status_im/chat/models/message.cljs

-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
[react-native.platform :as platform]
66
[status-im.chat.models.loading :as chat.loading]
77
[status-im.data-store.messages :as data-store.messages]
8-
[status-im.transport.message.protocol :as protocol]
98
[status-im.utils.deprecated-types :as types]
109
[status-im2.contexts.chat.messages.delete-message.events :as delete-message]
1110
[status-im2.contexts.chat.messages.list.events :as message-list]
@@ -21,12 +20,6 @@
2120
[db chat-id clock-value]
2221
(>= (get-in db [:chats chat-id :deleted-at-clock-value]) clock-value))
2322

24-
(defn add-timeline-message
25-
[acc chat-id message-id message]
26-
(-> acc
27-
(update-in [:db :messages chat-id] assoc message-id message)
28-
(update-in [:db :message-lists chat-id] message-list/add message)))
29-
3023
(defn hide-message
3124
"Hide chat message, rebuild message-list"
3225
[{:keys [db]} chat-id message-id]
@@ -145,14 +138,6 @@
145138
:on-error #(log/error "failed to re-send message" %)}]}
146139
(update-message-status chat-id message-id :sending)))
147140

148-
(rf/defn send-message
149-
[cofx message]
150-
(protocol/send-chat-messages cofx [message]))
151-
152-
(rf/defn send-messages
153-
[cofx messages]
154-
(protocol/send-chat-messages cofx messages))
155-
156141
(rf/defn handle-removed-messages
157142
{:events [::handle-removed-messages]}
158143
[{:keys [db] :as cofx} removed-messages]

src/status_im/chat/models/reactions.cljs

-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(:require
33
[re-frame.core :as re-frame]
44
[status-im.data-store.reactions :as data-store.reactions]
5-
[status-im.transport.message.protocol :as message.protocol]
65
[status-im2.constants :as constants]
76
[taoensso.timbre :as log]
87
[utils.re-frame :as rf]
@@ -63,23 +62,6 @@
6362
(let [reactions-w-chat-id (map #(assoc % :chat-id chat-id) reactions)]
6463
{:db (update db :reactions (process-reactions (:chats db)) reactions-w-chat-id)})))
6564

66-
67-
;; Send reactions
68-
69-
70-
(rf/defn send-emoji-reaction
71-
{:events [:models.reactions/send-emoji-reaction]}
72-
[{{:keys [current-chat-id]} :db :as cofx} reaction]
73-
(message.protocol/send-reaction cofx
74-
(update reaction :chat-id #(or % current-chat-id))))
75-
76-
(rf/defn send-retract-emoji-reaction
77-
{:events [:models.reactions/send-emoji-reaction-retraction]}
78-
[{{:keys [current-chat-id]} :db :as cofx} reaction]
79-
(message.protocol/send-retract-reaction cofx
80-
(update reaction :chat-id #(or % current-chat-id))))
81-
82-
8365
(defn message-reactions
8466
[current-public-key reactions]
8567
(reduce

src/status_im/events.cljs

-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
status-im.pairing.core
3333
status-im.profile.core
3434
status-im.search.core
35-
status-im.signals.core
3635
status-im.stickers.core
37-
status-im.transport.core
3836
status-im.ui.components.invite.events
3937
[status-im.ui.components.react :as react]
4038
status-im.ui.screens.notifications-settings.events

src/status_im/mailserver/core.cljs

+14
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,17 @@
412412
(rf/merge cofx
413413
{:db (dissoc db :mailserver.edit/mailserver)}
414414
(navigation/navigate-to :edit-mailserver nil)))
415+
416+
(defn add-mailservers
417+
[db mailservers]
418+
(reduce (fn [db {:keys [fleet id name] :as mailserver}]
419+
(let [updated-mailserver
420+
(-> mailserver
421+
(update :id keyword)
422+
(assoc :name (if (seq name) name id))
423+
(dissoc :fleet))]
424+
(assoc-in db
425+
[:mailserver/mailservers (keyword fleet) (keyword id)]
426+
updated-mailserver)))
427+
db
428+
mailservers))

src/status_im/transport/core.cljs

-58
Original file line numberDiff line numberDiff line change
@@ -1,58 +0,0 @@
1-
(ns ^{:doc "API to init and stop whisper messaging"} status-im.transport.core
2-
(:require
3-
[re-frame.core :as re-frame]
4-
[status-im.pairing.core :as pairing]
5-
[status-im.stickers.core :as stickers]
6-
status-im.transport.shh
7-
[status-im2.common.universal-links :as universal-links]
8-
[taoensso.timbre :as log]
9-
[utils.re-frame :as rf]))
10-
11-
(rf/defn set-node-info
12-
{:events [:transport.callback/node-info-fetched]}
13-
[{:keys [db]} node-info]
14-
{:db (assoc db :node-info node-info)})
15-
16-
(rf/defn fetch-node-info-fx
17-
[_]
18-
{:json-rpc/call [{:method "admin_nodeInfo"
19-
:on-success #(re-frame/dispatch [:transport.callback/node-info-fetched %])
20-
:on-error #(log/error "node-info: failed error" %)}]})
21-
22-
(defn add-mailservers
23-
[db mailservers]
24-
(reduce (fn [db {:keys [fleet id name] :as mailserver}]
25-
(let [updated-mailserver
26-
(-> mailserver
27-
(update :id keyword)
28-
(assoc :name (if (seq name) name id))
29-
(dissoc :fleet))]
30-
(assoc-in db
31-
[:mailserver/mailservers (keyword fleet) (keyword id)]
32-
updated-mailserver)))
33-
db
34-
mailservers))
35-
36-
(rf/defn start-messenger
37-
"We should only start receiving messages/processing topics once all the
38-
initializiation is completed, otherwise we might receive messages/topics
39-
when the state has not been properly initialized."
40-
[_]
41-
{:json-rpc/call [{:method "wakuext_startMessenger"
42-
:on-success #(re-frame/dispatch [::messenger-started %])
43-
:on-error #(log/error "failed to start messenger")}]})
44-
45-
(rf/defn messenger-started
46-
{:events [::messenger-started]}
47-
[{:keys [db] :as cofx} {:keys [mailservers] :as response}]
48-
(log/info "Messenger started")
49-
(let [new-account? (get db :onboarding/new-account?)]
50-
(rf/merge cofx
51-
{:db (-> db
52-
(assoc :messenger/started? true)
53-
(add-mailservers mailservers))}
54-
(fetch-node-info-fx)
55-
(pairing/init)
56-
(stickers/load-packs)
57-
(when-not new-account?
58-
(universal-links/process-stored-event)))))

src/status_im/transport/message/protocol.cljs

-59
This file was deleted.

src/status_im/transport/shh.cljs

-35
This file was deleted.

src/status_im/transport/utils.cljs

-18
This file was deleted.

src/status_im/utils/logging/core.cljs

+7-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
[react-native.mail :as react-native-mail]
88
[react-native.platform :as platform]
99
[status-im.bottom-sheet.events :as bottom-sheet]
10-
[status-im.transport.utils :as transport.utils]
1110
[status-im.ui.components.react :as react]
1211
[status-im.utils.build :as build]
1312
[status-im.utils.deprecated-types :as types]
@@ -38,6 +37,11 @@
3837
{:json-rpc/call [{:method "web3_clientVersion"
3938
:on-success #(re-frame/dispatch [:logging/store-web3-client-version %])}]})
4039

40+
(defn extract-url-components
41+
[address]
42+
(when address
43+
(rest (re-matches #"enode://(.*?)@(.*):(.*)" address))))
44+
4145
(defn email-body
4246
"logs attached"
4347
[{:keys [:web3-node-version :mailserver/current-id
@@ -46,7 +50,7 @@
4650
build-version (str build/version " (" build-number ")")
4751
separator (string/join (take 40 (repeat "-")))
4852
[enode-id ip-address port]
49-
(transport.utils/extract-url-components (:enode node-info))]
53+
(extract-url-components (:enode node-info))]
5054
(string/join
5155
"\n"
5256
(concat [(i18n/label :t/report-bug-email-template
@@ -68,7 +72,7 @@
6872
(mapcat
6973
(fn [{:keys [enode]}]
7074
(let [[enode-id ip-address port]
71-
(transport.utils/extract-url-components enode)]
75+
(extract-url-components enode)]
7276
[(str "id: " enode-id)
7377
(str "ip: " ip-address)
7478
(str "port: " port)

0 commit comments

Comments
 (0)