Safe deserialization of the last message's content
The issue was fixed in #7085 but reintroduced in #7055.
This commit is contained in:
parent
7fa46065a7
commit
8f48dc8df6
|
@ -55,7 +55,7 @@
|
||||||
(update :membership-updates (partial unmarshal-membership-updates chat-id))
|
(update :membership-updates (partial unmarshal-membership-updates chat-id))
|
||||||
(update :last-clock-value utils.clocks/safe-timestamp)
|
(update :last-clock-value utils.clocks/safe-timestamp)
|
||||||
(update :last-message-type keyword)
|
(update :last-message-type keyword)
|
||||||
(update :last-message-content edn/read-string)))
|
(update :last-message-content utils/safe-read-message-content)))
|
||||||
|
|
||||||
(re-frame/reg-cofx
|
(re-frame/reg-cofx
|
||||||
:data-store/all-chats
|
:data-store/all-chats
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
(ns status-im.data-store.messages
|
(ns status-im.data-store.messages
|
||||||
(:require [cljs.tools.reader.edn :as edn]
|
(:require [re-frame.core :as re-frame]
|
||||||
[taoensso.timbre :as log]
|
|
||||||
[re-frame.core :as re-frame]
|
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.data-store.realm.core :as core]
|
[status-im.data-store.realm.core :as core]
|
||||||
[status-im.utils.core :as utils]
|
[status-im.utils.core :as utils]
|
||||||
[status-im.js-dependencies :as dependencies]))
|
[status-im.js-dependencies :as dependencies]))
|
||||||
|
|
||||||
(defn- transform-message [message]
|
(defn- transform-message [{:keys [content] :as message}]
|
||||||
(try
|
(when-let [parsed-content (utils/safe-read-message-content content)]
|
||||||
(-> message
|
(-> message
|
||||||
(update :message-type keyword)
|
(update :message-type keyword)
|
||||||
(update :content edn/read-string))
|
(assoc :content parsed-content))))
|
||||||
(catch :default e
|
|
||||||
(log/warn "failed to transform message with " e))))
|
|
||||||
|
|
||||||
(defn- get-by-chat-id
|
(defn- get-by-chat-id
|
||||||
([chat-id]
|
([chat-id]
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
(ns status-im.utils.core
|
(ns status-im.utils.core
|
||||||
(:require [clojure.string :as str]))
|
(:require [clojure.string :as str]
|
||||||
|
[cljs.tools.reader.edn :as edn]
|
||||||
|
[taoensso.timbre :as log]))
|
||||||
|
|
||||||
(defn truncate-str
|
(defn truncate-str
|
||||||
"Given string and max threshold, trims the string to threshold length with `...`
|
"Given string and max threshold, trims the string to threshold length with `...`
|
||||||
|
@ -63,3 +65,9 @@
|
||||||
Similar to group-by except that the map values are single objects (depends on key uniqueness)."
|
Similar to group-by except that the map values are single objects (depends on key uniqueness)."
|
||||||
[key coll]
|
[key coll]
|
||||||
(into {} (map #(vector (key %) %) coll)))
|
(into {} (map #(vector (key %) %) coll)))
|
||||||
|
|
||||||
|
(defn safe-read-message-content [content]
|
||||||
|
(try
|
||||||
|
(edn/read-string content)
|
||||||
|
(catch :default e
|
||||||
|
(log/warn "failed to transform message with " e))))
|
||||||
|
|
Loading…
Reference in New Issue