diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-02-05 09:43:22 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-02-05 09:43:22 +0000 |
commit | a1a4960baf78c1a24f76c603076c832a1947360f (patch) | |
tree | b21bfb5fc0e95023b7a50f5f86fc82a655d34588 | |
parent | Add SimpleHttpClient.put_json with the same semantics as get_json. (diff) | |
download | synapse-a1a4960baf78c1a24f76c603076c832a1947360f.tar.xz |
Impl push_bulk function
-rw-r--r-- | synapse/appservice/api.py | 19 | ||||
-rw-r--r-- | synapse/handlers/appservice.py | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py index 74508ecddf..fbf4abc526 100644 --- a/synapse/appservice/api.py +++ b/synapse/appservice/api.py @@ -64,8 +64,25 @@ class ApplicationServiceApi(SimpleHttpClient): return logger.warning("query_alias to %s received %s", uri, e.code) + @defer.inlineCallbacks def push_bulk(self, service, events): - pass + uri = service.url + ("/transactions/%s" % + urllib.quote(str(0))) # TODO txn_ids + response = None + try: + response = yield self.put_json( + uri, + { + "events": events + }, + { + "access_token": self.hs_token + }) + if response: # just an empty json object + defer.returnValue(True) + except CodeMessageException as e: + logger.warning("push_bulk to %s received %s", uri, e.code) + defer.returnValue(False) @defer.inlineCallbacks def push(self, service, event): diff --git a/synapse/handlers/appservice.py b/synapse/handlers/appservice.py index dd860b2244..2b2761682f 100644 --- a/synapse/handlers/appservice.py +++ b/synapse/handlers/appservice.py @@ -56,7 +56,7 @@ class ApplicationServicesHandler(object): yield self.store.update_app_service(app_service) logger.info("Sending ping to %s...", app_service.url) - yield self.appservice_api.query_alias(app_service, "ping") + yield self.appservice_api.push(app_service, "pinger") def unregister(self, token): logger.info("Unregister as_token=%s", token) |