diff options
author | Mark Haines <mark.haines@matrix.org> | 2016-08-25 18:14:02 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2016-08-25 18:14:02 +0100 |
commit | 641efb6a39f0d913895cec73b1bda8dbb548c2a3 (patch) | |
tree | 3527796e1023de303290e0291e4ec593d3e14d5b /synapse/rest | |
parent | Add store-and-forward direct-to-device messaging (diff) | |
download | synapse-641efb6a39f0d913895cec73b1bda8dbb548c2a3.tar.xz |
Fix the deduplication of incoming direct-to-device messages
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/client/v2_alpha/sendtodevice.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/synapse/rest/client/v2_alpha/sendtodevice.py b/synapse/rest/client/v2_alpha/sendtodevice.py index 6180266499..42754e8774 100644 --- a/synapse/rest/client/v2_alpha/sendtodevice.py +++ b/synapse/rest/client/v2_alpha/sendtodevice.py @@ -19,6 +19,7 @@ from twisted.internet import defer from synapse.http.servlet import parse_json_object_from_request from synapse.http import servlet +from synapse.rest.client.v1.transactions import HttpTransactionStore from ._base import client_v2_patterns logger = logging.getLogger(__name__) @@ -40,9 +41,17 @@ class SendToDeviceRestServlet(servlet.RestServlet): self.auth = hs.get_auth() self.store = hs.get_datastore() self.is_mine_id = hs.is_mine_id + self.txns = HttpTransactionStore() @defer.inlineCallbacks def on_PUT(self, request, message_type, txn_id): + try: + defer.returnValue( + self.txns.get_client_transaction(request, txn_id) + ) + except KeyError: + pass + requester = yield self.auth.get_user_by_req(request) content = parse_json_object_from_request(request) @@ -62,7 +71,9 @@ class SendToDeviceRestServlet(servlet.RestServlet): yield self.store.add_messages_to_device_inbox(local_messages) - defer.returnValue((200, {})) + response = (200, {}) + self.txns.store_client_transaction(request, txn_id, response) + defer.returnValue(response) def register_servlets(hs, http_server): |