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
(group-by :signature)
(map (fn [[signature events]]
{:events (map #(-> %
(assoc :clock-value (:clockValue %))
(dissoc :signature :from :id :clockValue)
remove-empty-vals) events)
{:events
(into []
(sort-by :clock-value (map #(-> %
(assoc :clock-value (:clockValue %))
(update :members (fn [members] (into #{} members)))
(dissoc :signature :from :id :clockValue)
remove-empty-vals) events)))
:from (-> events first :from)
:signature signature
:chat-id chat-id}))))
:chat-id chat-id}))
(into #{})))
(defn type->rpc [{:keys [public? group-chat] :as chat}]
(assoc chat :chatType (cond

View File

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