diff options
author | Erik Johnston <erik@matrix.org> | 2019-01-23 16:50:06 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-01-23 16:51:46 +0000 |
commit | 67cd4dad81ed2932009472da2d13648ca11eab73 (patch) | |
tree | 2e95db3676cc00b59b2853c6066b91b65bfb91a0 /synapse/events | |
parent | isort (diff) | |
download | synapse-67cd4dad81ed2932009472da2d13648ca11eab73.tar.xz |
Implement MSC 1813 - Add room version to make APIs
We also implement `make_membership_event` converting the returned room version to an event format version.
Diffstat (limited to 'synapse/events')
-rw-r--r-- | synapse/events/__init__.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py index 9dd6940385..e6f94e68af 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 @@ -235,3 +235,18 @@ 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: + raise + + return EventFormatVersions.V1 |