summary refs log tree commit diff
path: root/synapse/events
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2019-01-25 10:27:25 +0000
committerGitHub <noreply@github.com>2019-01-25 10:27:25 +0000
commit28c21cd578587a1890ebf739fde94b2375cb4429 (patch)
tree69514e969311bdee344e51a524969c73c0fdb066 /synapse/events
parentMerge pull request #4469 from matrix-org/revert-4451-erikj/require_format_ver... (diff)
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/msc_1813 (diff)
downloadsynapse-28c21cd578587a1890ebf739fde94b2375cb4429.tar.xz
Merge pull request #4447 from matrix-org/erikj/msc_1813
Implement MSC 1813 - Add room version to make APIs
Diffstat (limited to 'synapse/events')
-rw-r--r--synapse/events/__init__.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index 888296933b..38470ad176 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -18,7 +18,7 @@ from distutils.util import strtobool
 
 import six
 
-from synapse.api.constants import EventFormatVersions
+from synapse.api.constants import KNOWN_ROOM_VERSIONS, EventFormatVersions
 from synapse.util.caches import intern_dict
 from synapse.util.frozenutils import freeze
 
@@ -240,3 +240,19 @@ class FrozenEvent(EventBase):
             self.get("type", None),
             self.get("state_key", None),
         )
+
+
+def room_version_to_event_format(room_version):
+    """Converts a room version string to the event format
+
+    Args:
+        room_version (str)
+
+    Returns:
+        int
+    """
+    if room_version not in KNOWN_ROOM_VERSIONS:
+        # We should have already checked version, so this should not happen
+        raise RuntimeError("Unrecognized room version %s" % (room_version,))
+
+    return EventFormatVersions.V1