Fix serialization of group-chats

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-08-20 13:29:01 +02:00
parent da7a69bc02
commit 79ab816497
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
2 changed files with 18 additions and 14 deletions

View File

@ -49,13 +49,17 @@
(->> updates (->> updates
(group-by :signature) (group-by :signature)
(map (fn [[signature events]] (map (fn [[signature events]]
{:events (map #(-> % {:events
(assoc :clock-value (:clockValue %)) (into []
(dissoc :signature :from :id :clockValue) (sort-by :clock-value (map #(-> %
remove-empty-vals) events) (assoc :clock-value (:clockValue %))
(update :members (fn [members] (into #{} members)))
(dissoc :signature :from :id :clockValue)
remove-empty-vals) events)))
:from (-> events first :from) :from (-> events first :from)
:signature signature :signature signature
:chat-id chat-id})))) :chat-id chat-id}))
(into #{})))
(defn type->rpc [{:keys [public? group-chat] :as chat}] (defn type->rpc [{:keys [public? group-chat] :as chat}]
(assoc chat :chatType (cond (assoc chat :chatType (cond

View File

@ -121,15 +121,15 @@
:admins #{"a" "b"} :admins #{"a" "b"}
:members-joined #{"a" "c"} :members-joined #{"a" "c"}
:name "name" :name "name"
:membership-updates [{:chat-id "chat-id" :membership-updates #{{:chat-id "chat-id"
:from "a" :from "a"
:signature "b" :signature "b"
:events [{:type "chat-created" :events [{:type "chat-created"
:name "test" :name "test"
:clock-value 1} :clock-value 1}
{:type "members-added" {:type "members-added"
:clock-value 2 :clock-value 2
:members ["a" "b"]}]}] :members #{"a" "b"}}]}}
:unviewed-messages-count 2 :unviewed-messages-count 2
:is-active true :is-active true
:group-chat-local-version 1 :group-chat-local-version 1