summary refs log tree commit diff
path: root/synapse/federation/federation_base.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-12-30 18:40:19 +0000
committerRichard van der Hoff <richard@matrix.org>2017-12-30 18:40:19 +0000
commit3079f80d4a67714294660e27214cd2a55bb7ecf1 (patch)
treed936f2cab0c0f68c54caa182cc006fb181d1e54d /synapse/federation/federation_base.py
parentfederation_server: clean up imports (diff)
downloadsynapse-3079f80d4a67714294660e27214cd2a55bb7ecf1.tar.xz
Factor out `event_from_pdu_json`
turns out we have two copies of this, and neither needs to be an instance
method
Diffstat (limited to 'synapse/federation/federation_base.py')
-rw-r--r--synapse/federation/federation_base.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py
index a0f5d40eb3..6476cea895 100644
--- a/synapse/federation/federation_base.py
+++ b/synapse/federation/federation_base.py
@@ -16,6 +16,7 @@ import logging
 
 from synapse.api.errors import SynapseError
 from synapse.crypto.event_signing import check_event_content_hash
+from synapse.events import FrozenEvent
 from synapse.events.utils import prune_event
 from synapse.util import unwrapFirstError, logcontext
 from twisted.internet import defer
@@ -169,3 +170,22 @@ class FederationBase(object):
             )
 
         return deferreds
+
+
+def event_from_pdu_json(pdu_json, outlier=False):
+    """Construct a FrozenEvent from an event json received over federation
+
+    Args:
+        pdu_json (object): pdu as received over federation
+        outlier (bool): True to mark this event as an outlier
+
+    Returns:
+        FrozenEvent
+    """
+    event = FrozenEvent(
+        pdu_json
+    )
+
+    event.internal_metadata.outlier = outlier
+
+    return event