summary refs log tree commit diff
path: root/synapse/events
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-07-16 10:36:38 -0400
committerGitHub <noreply@github.com>2021-07-16 10:36:38 -0400
commitd427f64724569d606add3c1e6f3008bdd82c092d (patch)
tree9303df2b4b45ed64c62e9ff2320a56142352a4e6 /synapse/events
parentUse inline type hints in `http/federation/`, `storage/` and `util/` (#10381) (diff)
downloadsynapse-d427f64724569d606add3c1e6f3008bdd82c092d.tar.xz
Do not include signatures/hashes in make_{join,leave,knock} responses. (#10404)
These signatures would end up invalid since the joining/leaving/knocking
server would modify the response before calling send_{join,leave,knock}.
Diffstat (limited to 'synapse/events')
-rw-r--r--synapse/events/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index 65dc7a4ed0..0298af4c02 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -291,6 +291,20 @@ class EventBase(metaclass=abc.ABCMeta):
 
         return pdu_json
 
+    def get_templated_pdu_json(self) -> JsonDict:
+        """
+        Return a JSON object suitable for a templated event, as used in the
+        make_{join,leave,knock} workflow.
+        """
+        # By using _dict directly we don't pull in signatures/unsigned.
+        template_json = dict(self._dict)
+        # The hashes (similar to the signature) need to be recalculated by the
+        # joining/leaving/knocking server after (potentially) modifying the
+        # event.
+        template_json.pop("hashes")
+
+        return template_json
+
     def __set__(self, instance, value):
         raise AttributeError("Unrecognized attribute %s" % (instance,))