diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-10-09 18:50:15 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-10-09 18:50:15 +0100 |
commit | c15cf6ac069386df3095b5c69af96f0c76ce5276 (patch) | |
tree | 3829b38b12a57bfe9d130fbdd0cfb74d108eeb0b /synapse/rest/client/v2_alpha/sync.py | |
parent | Update the v2 room sync format to match the current v2 spec (diff) | |
download | synapse-c15cf6ac069386df3095b5c69af96f0c76ce5276.tar.xz |
Format the presence events correctly for v2
Diffstat (limited to 'synapse/rest/client/v2_alpha/sync.py')
-rw-r--r-- | synapse/rest/client/v2_alpha/sync.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/synapse/rest/client/v2_alpha/sync.py b/synapse/rest/client/v2_alpha/sync.py index 97bf95acfb..f20b830eda 100644 --- a/synapse/rest/client/v2_alpha/sync.py +++ b/synapse/rest/client/v2_alpha/sync.py @@ -26,6 +26,7 @@ from synapse.events.utils import ( from synapse.api.filtering import Filter from ._base import client_v2_pattern +import copy import logging logger = logging.getLogger(__name__) @@ -129,7 +130,7 @@ class SyncRestServlet(RestServlet): ) response_content = { - "presence": self.encode_user_data( + "presence": self.encode_presence( sync_result.presence, filter, time_now ), "rooms": rooms, @@ -138,8 +139,13 @@ class SyncRestServlet(RestServlet): defer.returnValue((200, response_content)) - def encode_user_data(self, events, filter, time_now): - return events + def encode_presence(self, events, filter, time_now): + formatted = [] + for event in events: + event = copy.deepcopy(event) + event['sender'] = event['content'].pop('user_id'); + formatted.append(event) + return {"events": formatted} def encode_rooms(self, rooms, filter, time_now, token_id): joined = {} |