diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-02-05 13:42:35 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-02-05 13:42:35 +0000 |
commit | 0613666d9c417005393636b935593c423f4417b9 (patch) | |
tree | 8e7761a0f0e23e909b945a0d88a2bd697df6f713 | |
parent | Fix unit tests. (diff) | |
download | synapse-0613666d9c417005393636b935593c423f4417b9.tar.xz |
Serialize events before sending to ASes
-rw-r--r-- | synapse/appservice/api.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py index d96caf7f58..9cce4e0973 100644 --- a/synapse/appservice/api.py +++ b/synapse/appservice/api.py @@ -16,6 +16,7 @@ from twisted.internet import defer from synapse.api.errors import CodeMessageException from synapse.http.client import SimpleHttpClient +from synapse.events.utils import serialize_event import logging import urllib @@ -30,6 +31,7 @@ class ApplicationServiceApi(SimpleHttpClient): def __init__(self, hs): super(ApplicationServiceApi, self).__init__(hs) + self.clock = hs.get_clock() @defer.inlineCallbacks def query_user(self, service, user_id): @@ -72,6 +74,8 @@ class ApplicationServiceApi(SimpleHttpClient): @defer.inlineCallbacks def push_bulk(self, service, events): + events = self._serialize(events) + uri = service.url + ("/transactions/%s" % urllib.quote(str(0))) # TODO txn_ids response = None @@ -98,3 +102,9 @@ class ApplicationServiceApi(SimpleHttpClient): response = yield self.push_bulk(service, [event]) defer.returnValue(response) + def _serialize(self, events): + time_now = self.clock.time_msec() + return [ + serialize_event(e, time_now, as_client_event=True) for e in events + ] + |