summary refs log tree commit diff
path: root/synapse/rest/client
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-05-15 17:28:33 +0100
committerErik Johnston <erik@matrix.org>2019-05-15 17:28:33 +0100
commite6459c26b45866558056bee991024e093e0de059 (patch)
treee5712db4e3e40a3c27c57de6d8208128c43d3d02 /synapse/rest/client
parentNewsfile (diff)
downloadsynapse-e6459c26b45866558056bee991024e093e0de059.tar.xz
Actually implement idempotency
Diffstat (limited to 'synapse/rest/client')
-rw-r--r--synapse/rest/client/v2_alpha/relations.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/rest/client/v2_alpha/relations.py b/synapse/rest/client/v2_alpha/relations.py
index bac9e85c21..c3ac73b8c7 100644
--- a/synapse/rest/client/v2_alpha/relations.py
+++ b/synapse/rest/client/v2_alpha/relations.py
@@ -31,6 +31,7 @@ from synapse.http.servlet import (
     parse_json_object_from_request,
     parse_string,
 )
+from synapse.rest.client.transactions import HttpTransactionCache
 
 from ._base import client_v2_patterns
 
@@ -59,6 +60,7 @@ class RelationSendServlet(RestServlet):
         super(RelationSendServlet, self).__init__()
         self.auth = hs.get_auth()
         self.event_creation_handler = hs.get_event_creation_handler()
+        self.txns = HttpTransactionCache(hs)
 
     def register(self, http_server):
         http_server.register_paths(
@@ -69,7 +71,12 @@ class RelationSendServlet(RestServlet):
         http_server.register_paths(
             "PUT",
             client_v2_patterns(self.PATTERN + "/(?P<txn_id>[^/]*)$", releases=()),
-            self.on_PUT_or_POST,
+            self.on_PUT,
+        )
+
+    def on_PUT(self, request, *args, **kwargs):
+        return self.txns.fetch_or_execute_request(
+            request, self.on_PUT_or_POST, request, *args, **kwargs
         )
 
     @defer.inlineCallbacks