Hide unknown referenced messages

This commit is contained in:
janherich 2018-10-12 17:32:42 +02:00 committed by Roman Volosovskyi
parent 5eeda7aa0b
commit b8fa4f5cbd
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 12 additions and 11 deletions

View File

@ -136,8 +136,8 @@
(defn quoted-message-data (defn quoted-message-data
"Selects certain data from quoted message which must be available in the view" "Selects certain data from quoted message which must be available in the view"
[message-id messages referenced-messages] [message-id messages referenced-messages]
(let [{:keys [from content]} (get messages message-id (when-let [{:keys [from content]} (get messages message-id
(get referenced-messages message-id))] (get referenced-messages message-id))]
{:from from {:from from
:text (:text content)})) :text (:text content)}))
@ -149,15 +149,16 @@
(into (list {:value datemark (into (list {:value datemark
:type :datemark}) :type :datemark})
(map (fn [{:keys [message-id timestamp-str]}] (map (fn [{:keys [message-id timestamp-str]}]
(let [{:keys [content] :as message} (get messages message-id)] (let [{:keys [content] :as message} (get messages message-id)
(cond-> (assoc message quote (some-> (:response-to content)
:datemark datemark (quoted-message-data messages referenced-messages))]
:timestamp-str timestamp-str (cond-> (-> message
:user-statuses (get message-statuses message-id)) (update :content dissoc :response-to)
(:response-to content) ;; quoted message reference (assoc :datemark datemark
(assoc-in [:content :response-to] (quoted-message-data (:response-to content) :timestamp-str timestamp-str
messages :user-statuses (get message-statuses message-id)))
referenced-messages)))))) quote ;; quoted message reference
(assoc-in [:content :response-to] quote)))))
message-references)) message-references))
message-groups)) message-groups))