diff --git a/src/status_im/chat/models/input.cljs b/src/status_im/chat/models/input.cljs index ded8edfdeb..6b7fc42a9f 100644 --- a/src/status_im/chat/models/input.cljs +++ b/src/status_im/chat/models/input.cljs @@ -133,7 +133,7 @@ :content (cond-> {:chat-id current-chat-id :text input-text} message-id - (assoc :response-to-v2 message-id) + (assoc :response-to message-id) preferred-name (assoc :name preferred-name))}) (commands.input/set-command-reference nil) diff --git a/src/status_im/chat/models/message_content.cljs b/src/status_im/chat/models/message_content.cljs index 905fe96635..20fda0f0e2 100644 --- a/src/status_im/chat/models/message_content.cljs +++ b/src/status_im/chat/models/message_content.cljs @@ -105,7 +105,7 @@ (defn emoji-only-content? "Determines if text is just an emoji" - [{:keys [text response-to-v2]}] - (and (not response-to-v2) + [{:keys [text response-to]}] + (and (not response-to) (string? text) (re-matches constants/regx-emoji text))) diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index e3da1ff6af..a2d2aaac49 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -28,7 +28,7 @@ :content-type :contentType :clock-value :clockValue :outgoing-status :outgoingStatus}) - (assoc :replyTo (get-in message [:content :response-to-v2])))) + (assoc :replyTo (get-in message [:content :response-to])))) (defn update-quoted-message [message] (let [parsed-content (utils/safe-read-message-content (get-in message [:quotedMessage :content]))] diff --git a/src/status_im/transport/db.cljs b/src/status_im/transport/db.cljs index 48bdd8b196..605393ca6d 100644 --- a/src/status_im/transport/db.cljs +++ b/src/status_im/transport/db.cljs @@ -53,7 +53,6 @@ (spec/def :message.content/text (spec/and string? (complement s/blank?))) (spec/def :message.content/response-to string?) -(spec/def :message.content/response-to-v2 string?) (spec/def :message.content/command-path (spec/tuple string? (spec/coll-of (spec/or :scope keyword? :chat-id string?) :kind set? :min-count 1))) (spec/def :message.content/uri (spec/and string? (complement s/blank?))) (spec/def :message.content/pack (spec/and string? (complement s/blank?))) diff --git a/src/status_im/transport/message/core.cljs b/src/status_im/transport/message/core.cljs index d3cf5fc1ba..81613925ca 100644 --- a/src/status_im/transport/message/core.cljs +++ b/src/status_im/transport/message/core.cljs @@ -16,6 +16,31 @@ [taoensso.timbre :as log] [status-im.ethereum.json-rpc :as json-rpc])) +(def message-type-message 1) + +(defn build-message [parsed-message-js] + (let [content (.-content parsed-message-js) + built-message + (protocol/Message. + {:text (.-text content) + :response-to (.-response-to content) + :chat-id (.-chat_id content)} + (.-content_type parsed-message-js) + (keyword (.-message_type parsed-message-js)) + (.-clock parsed-message-js) + (.-timestamp parsed-message-js))] + built-message)) + +(defn handle-message + "Check if parsedMessage is present and of a supported type, if so + build a record using the right type. Otherwise defaults to transit + deserializing" + [message-js] + (if (and (.-parsedMessage message-js) + (= message-type-message) (.-messageType message-js)) + (build-message (.-parsedMessage message-js)) + (transit/deserialize (.-payload message-js)))) + (fx/defn receive-message "Receive message handles a new status-message. dedup-id is passed by status-go and is used to deduplicate messages at that layer. @@ -23,7 +48,6 @@ in order to stop receiving that message" [{:keys [db]} now-in-s filter-chat-id message-js] (let [blocked-contacts (get db :contacts/blocked #{}) - payload (.-payload message-js) timestamp (.-timestamp (.-message message-js)) metadata-js (.-metadata message-js) metadata {:author {:publicKey (.-publicKey (.-author metadata-js)) @@ -32,9 +56,7 @@ :dedupId (.-dedupId metadata-js) :encryptionId (.-encryptionId metadata-js) :messageId (.-messageId metadata-js)} - raw-payload {:raw-payload message-js} - status-message (-> payload - transit/deserialize) + status-message (handle-message message-js) sig (-> metadata :author :publicKey)] (when (and sig status-message diff --git a/src/status_im/ui/screens/chat/message/message.cljs b/src/status_im/ui/screens/chat/message/message.cljs index aba9f8b82f..5c267957ed 100644 --- a/src/status_im/ui/screens/chat/message/message.cljs +++ b/src/status_im/ui/screens/chat/message/message.cljs @@ -70,9 +70,7 @@ [{:keys [chat-id message-id content timestamp-str group-chat outgoing current-public-key expanded?] :as message}] [message-view message - (let [response-to (or (:response-to content) - (:response-to-v2 content)) - + (let [response-to (:response-to content) collapsible? (and (:should-collapse? content) group-chat)] [react/view (when response-to @@ -98,8 +96,7 @@ (defn emoji-message [{:keys [content current-public-key alias] :as message}] - (let [response-to (or (:response-to content) - (:response-to-v2 content))] + (let [response-to (:response-to content)] [message-view message [react/view {:style (style/style-message-text false)} (when response-to diff --git a/status-go-version.json b/status-go-version.json index 2aa4fadd37..10d7e64e01 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.34.0-beta.4", - "commit-sha1": "e311307061ebf67fece33ff02e811d94972ae5b1", - "src-sha256": "063yfb9r1vdgskhfqg0r400wrpwk2ibryc785pffwash70yyf5y0" + "version": "v0.34.0-beta.6", + "commit-sha1": "9d6601207f7bb2acf0ef0b952b2735995062fca7", + "src-sha256": "1w6c8vgawnd48ygarh18gjzzf3x90zidsi7kiwszmygfd7dh0dp8" } diff --git a/test/cljs/status_im/test/data_store/messages.cljs b/test/cljs/status_im/test/data_store/messages.cljs index 69d8bb71b5..5187c2ae9f 100644 --- a/test/cljs/status_im/test/data_store/messages.cljs +++ b/test/cljs/status_im/test/data_store/messages.cljs @@ -10,7 +10,7 @@ (testing "message to rpc" (let [message {:message-id message-id :content {:chat-id chat-id - :response-to-v2 "id-2" + :response-to "id-2" :text "hta"} :whisper-timestamp 1 :dedup-id "ATIwMTkwODE0YTdkNWZhZGY1N2E0ZDU3MzUxZmJkNDZkZGM1ZTU4ZjRlYzUyYWYyMDA5NTc2NWYyYmIxOTQ2OTM3NGUwNjdiMvEpTIGEjHOTAyqsrN39wST4npnSAv1AR8jJWeubanjkoGIyJooD5RVRnx6ZMt+/JzBOD2hoZzlHQWA0bC6XbdU=" @@ -26,7 +26,7 @@ :from from :chatId chat-id :replyTo "id-2" - :content "{\"chat-id\":\"chat-id\",\"response-to-v2\":\"id-2\",\"text\":\"hta\"}" + :content "{\"chat-id\":\"chat-id\",\"response-to\":\"id-2\",\"text\":\"hta\"}" :contentType "text/plain" :messageType "public-group-user-message" :clockValue 2