File tree 3 files changed +12
-16
lines changed
src/status_im/chat/commands
test/cljs/status_im/test/chat/commands
3 files changed +12
-16
lines changed Original file line number Diff line number Diff line change 6
6
[status-im.chat.constants :as chat.constants]
7
7
[status-im.chat.commands.protocol :as protocol]
8
8
[status-im.chat.commands.impl.transactions :as transactions]
9
- [status-im.contact.db :as db]
10
9
[status-im.utils.handlers :as handlers]
11
10
[status-im.utils.fx :as fx]))
12
11
35
34
[type]
36
35
(keyword (str (protocol/id type) " -button" )))
37
36
38
- (defn- contact->address [contact]
39
- (str " 0x" (db/public-key->address contact)))
40
-
41
37
(defn add-chat-contacts
42
38
" Enrich command-message by adding contact list of the current private or group chat"
43
39
[contacts {:keys [public? group-chat] :as command-message}]
44
40
(cond
45
41
public? command-message
46
- group-chat (assoc command-message :contacts (map contact->address contacts))
47
- :else (assoc command-message :contact (contact->address (first contacts)))))
42
+ group-chat (assoc command-message :contacts (map status-im. contact.db/public-key ->address contacts))
43
+ :else (assoc command-message :contact (status-im. contact.db/public-key ->address (first contacts)))))
48
44
49
45
(defn enrich-command-message-for-events
50
46
" adds new pairs to command-message to be consumed by extension events"
Original file line number Diff line number Diff line change 31
31
; ; errors during validation
32
32
{:db (chat/set-chat-ui-props db {:validation-messages validation-error})}
33
33
; ; no errors
34
- (let [command-message ( commands/enrich-command-message-for-events db ( create-command-message chat-id type parameter-map cofx))]
35
- ( if ( satisfies? protocol/Yielding type)
36
- ; ; yield control implemented, don't send the message
37
- ( protocol/ yield- control type command-message cofx)
38
- ; ; no yield control, proceed with sending the command message
34
+ (if ( satisfies? protocol/Yielding type)
35
+ ; ; yield control implemented, don't send the message
36
+ ( protocol/ yield- control type parameter-map cofx)
37
+ ; ; no yield control, proceed with sending the command message
38
+ ( let [command-message ( create-command-message chat-id type parameter-map cofx)]
39
39
(fx/merge cofx
40
- #(protocol/on-send type command-message %)
40
+ #(protocol/on-send type ( commands/enrich- command-message-for-events db command-message) %)
41
41
(commands.input/set-command-reference nil )
42
42
(chat.message/send-message command-message)))))))
43
43
Original file line number Diff line number Diff line change 111
111
" 0x04b790f2c3f4079f35a1fa396465ceb243cc446c9af211d0a1774f869eb9632a67a6e664e24075ec5c5a8a95a509a2a8173dbfeb88af372e784a37fecc1b5c0ba5"
112
112
" 0x04cc3cec3f88dc1a39e224388f0304023fc78c2a7d05e4ebd61638192cc592d2c13d8f081b5d9995dbfcbe45a4ca7eb80d5c505eee660e8fee0df2da222f047287" })
113
113
114
- (def contacts_addresses '(" 0x5adf1b9e1fa4bd4889fecd598b45079045d98f0e "
115
- " 0x21631d18d9681d4ffdd460fc45fa52159fcd95c8 "
116
- " 0x5541e3be81b76d76cdbf968516caa5a5b773763b " ))
114
+ (def contacts_addresses '(" 5adf1b9e1fa4bd4889fecd598b45079045d98f0e "
115
+ " 21631d18d9681d4ffdd460fc45fa52159fcd95c8 "
116
+ " 5541e3be81b76d76cdbf968516caa5a5b773763b " ))
117
117
118
118
(deftest enrich-command-message-for-events-test-public
119
119
(let [db {:chats {" 1" {:contacts nil :public? true :group-chat false }}}
137
137
enriched-msg (core/enrich-command-message-for-events db msg)]
138
138
(testing " command-message correctly enriched - 1on1 chat"
139
139
(is (= enriched-msg
140
- (assoc msg :public? false :group-chat false :contact (first contacts_addresses)))))))
140
+ (assoc msg :public? false :group-chat false :contact (first contacts_addresses)))))))
You can’t perform that action at this time.
0 commit comments