summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/api/room_versions.py36
-rw-r--r--synapse/event_auth.py6
-rw-r--r--synapse/events/__init__.py18
-rw-r--r--synapse/events/builder.py6
-rw-r--r--synapse/events/validator.py4
-rw-r--r--synapse/federation/federation_base.py4
-rw-r--r--synapse/federation/federation_client.py4
-rw-r--r--synapse/storage/databases/main/event_federation.py4
-rw-r--r--synapse/storage/databases/main/events_worker.py12
9 files changed, 47 insertions, 47 deletions
diff --git a/synapse/api/room_versions.py b/synapse/api/room_versions.py
index 3de9eeeca9..cc30092ee5 100644
--- a/synapse/api/room_versions.py
+++ b/synapse/api/room_versions.py
@@ -17,7 +17,7 @@ from typing import Callable, Dict, Optional
 import attr
 
 
-class EventFormatVersions(Enum):
+class EventFormatVersion(Enum):
     """This is an internal enum for tracking the version of the event format,
     independently of the room version.
 
@@ -33,9 +33,9 @@ class EventFormatVersions(Enum):
 
 
 KNOWN_EVENT_FORMAT_VERSIONS = {
-    EventFormatVersions.ROOM_V1_V2,
-    EventFormatVersions.ROOM_V3,
-    EventFormatVersions.ROOM_V4_PLUS,
+    EventFormatVersion.ROOM_V1_V2,
+    EventFormatVersion.ROOM_V3,
+    EventFormatVersion.ROOM_V4_PLUS,
 }
 
 
@@ -57,7 +57,7 @@ class RoomVersion:
 
     identifier: str  # the identifier for this version
     disposition: str  # one of the RoomDispositions
-    event_format: EventFormatVersions  # one of the EventFormatVersions
+    event_format: EventFormatVersion  # one of the EventFormatVersions
     state_res: int  # one of the StateResolutionVersions
     enforce_key_validity: bool
 
@@ -97,7 +97,7 @@ class RoomVersions:
     V1 = RoomVersion(
         "1",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V1_V2,
+        EventFormatVersion.ROOM_V1_V2,
         StateResolutionVersions.V1,
         enforce_key_validity=False,
         special_case_aliases_auth=True,
@@ -115,7 +115,7 @@ class RoomVersions:
     V2 = RoomVersion(
         "2",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V1_V2,
+        EventFormatVersion.ROOM_V1_V2,
         StateResolutionVersions.V2,
         enforce_key_validity=False,
         special_case_aliases_auth=True,
@@ -133,7 +133,7 @@ class RoomVersions:
     V3 = RoomVersion(
         "3",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V3,
+        EventFormatVersion.ROOM_V3,
         StateResolutionVersions.V2,
         enforce_key_validity=False,
         special_case_aliases_auth=True,
@@ -151,7 +151,7 @@ class RoomVersions:
     V4 = RoomVersion(
         "4",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=False,
         special_case_aliases_auth=True,
@@ -169,7 +169,7 @@ class RoomVersions:
     V5 = RoomVersion(
         "5",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=True,
@@ -187,7 +187,7 @@ class RoomVersions:
     V6 = RoomVersion(
         "6",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
@@ -205,7 +205,7 @@ class RoomVersions:
     MSC2176 = RoomVersion(
         "org.matrix.msc2176",
         RoomDisposition.UNSTABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
@@ -223,7 +223,7 @@ class RoomVersions:
     V7 = RoomVersion(
         "7",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
@@ -241,7 +241,7 @@ class RoomVersions:
     V8 = RoomVersion(
         "8",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
@@ -259,7 +259,7 @@ class RoomVersions:
     V9 = RoomVersion(
         "9",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
@@ -277,7 +277,7 @@ class RoomVersions:
     MSC3787 = RoomVersion(
         "org.matrix.msc3787",
         RoomDisposition.UNSTABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
@@ -295,7 +295,7 @@ class RoomVersions:
     V10 = RoomVersion(
         "10",
         RoomDisposition.STABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
@@ -313,7 +313,7 @@ class RoomVersions:
     MSC2716v4 = RoomVersion(
         "org.matrix.msc2716v4",
         RoomDisposition.UNSTABLE,
-        EventFormatVersions.ROOM_V4_PLUS,
+        EventFormatVersion.ROOM_V4_PLUS,
         StateResolutionVersions.V2,
         enforce_key_validity=True,
         special_case_aliases_auth=False,
diff --git a/synapse/event_auth.py b/synapse/event_auth.py
index c7d5ef92fc..02bd36bf25 100644
--- a/synapse/event_auth.py
+++ b/synapse/event_auth.py
@@ -39,7 +39,7 @@ from synapse.api.errors import (
 )
 from synapse.api.room_versions import (
     KNOWN_ROOM_VERSIONS,
-    EventFormatVersions,
+    EventFormatVersion,
     RoomVersion,
 )
 from synapse.storage.databases.main.events_worker import EventRedactBehaviour
@@ -109,7 +109,7 @@ def validate_event_for_room_version(event: "EventBase") -> None:
         if not is_invite_via_3pid:
             raise AuthError(403, "Event not signed by sender's server")
 
-    if event.format_version in (EventFormatVersions.ROOM_V1_V2,):
+    if event.format_version in (EventFormatVersion.ROOM_V1_V2,):
         # Only older room versions have event IDs to check.
         event_id_domain = get_domain_from_id(event.event_id)
 
@@ -716,7 +716,7 @@ def check_redaction(
     if user_level >= redact_level:
         return False
 
-    if room_version_obj.event_format == EventFormatVersions.ROOM_V1_V2:
+    if room_version_obj.event_format == EventFormatVersion.ROOM_V1_V2:
         redacter_domain = get_domain_from_id(event.event_id)
         if not isinstance(event.redacts, str):
             return False
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py
index 2afaa8e77c..454e01445a 100644
--- a/synapse/events/__init__.py
+++ b/synapse/events/__init__.py
@@ -38,7 +38,7 @@ from typing_extensions import Literal
 from unpaddedbase64 import encode_base64
 
 from synapse.api.constants import RelationTypes
-from synapse.api.room_versions import EventFormatVersions, RoomVersion, RoomVersions
+from synapse.api.room_versions import EventFormatVersion, RoomVersion, RoomVersions
 from synapse.types import JsonDict, RoomStreamToken
 from synapse.util.caches import intern_dict
 from synapse.util.frozenutils import freeze
@@ -293,7 +293,7 @@ class _EventInternalMetadata:
 class EventBase(metaclass=abc.ABCMeta):
     @property
     @abc.abstractmethod
-    def format_version(self) -> EventFormatVersions:
+    def format_version(self) -> EventFormatVersion:
         """The EventFormatVersion implemented by this event"""
         ...
 
@@ -442,7 +442,7 @@ class EventBase(metaclass=abc.ABCMeta):
 
 
 class FrozenEvent(EventBase):
-    format_version = EventFormatVersions.ROOM_V1_V2  # All events of this type are V1
+    format_version = EventFormatVersion.ROOM_V1_V2  # All events of this type are V1
 
     def __init__(
         self,
@@ -490,7 +490,7 @@ class FrozenEvent(EventBase):
 
 
 class FrozenEventV2(EventBase):
-    format_version = EventFormatVersions.ROOM_V3  # All events of this type are V2
+    format_version = EventFormatVersion.ROOM_V3  # All events of this type are V2
 
     def __init__(
         self,
@@ -567,7 +567,7 @@ class FrozenEventV2(EventBase):
 class FrozenEventV3(FrozenEventV2):
     """FrozenEventV3, which differs from FrozenEventV2 only in the event_id format"""
 
-    format_version = EventFormatVersions.ROOM_V4_PLUS  # All events of this type are V3
+    format_version = EventFormatVersion.ROOM_V4_PLUS  # All events of this type are V3
 
     @property
     def event_id(self) -> str:
@@ -584,7 +584,7 @@ class FrozenEventV3(FrozenEventV2):
 
 
 def _event_type_from_format_version(
-    format_version: EventFormatVersions,
+    format_version: EventFormatVersion,
 ) -> Type[Union[FrozenEvent, FrozenEventV2, FrozenEventV3]]:
     """Returns the python type to use to construct an Event object for the
     given event format version.
@@ -597,11 +597,11 @@ def _event_type_from_format_version(
         `FrozenEvent`
     """
 
-    if format_version == EventFormatVersions.ROOM_V1_V2:
+    if format_version == EventFormatVersion.ROOM_V1_V2:
         return FrozenEvent
-    elif format_version == EventFormatVersions.ROOM_V3:
+    elif format_version == EventFormatVersion.ROOM_V3:
         return FrozenEventV2
-    elif format_version == EventFormatVersions.ROOM_V4_PLUS:
+    elif format_version == EventFormatVersion.ROOM_V4_PLUS:
         return FrozenEventV3
     else:
         raise Exception("No event format %r" % (format_version,))
diff --git a/synapse/events/builder.py b/synapse/events/builder.py
index 746bd3978d..2c36164ca2 100644
--- a/synapse/events/builder.py
+++ b/synapse/events/builder.py
@@ -20,7 +20,7 @@ from signedjson.types import SigningKey
 from synapse.api.constants import MAX_DEPTH
 from synapse.api.room_versions import (
     KNOWN_EVENT_FORMAT_VERSIONS,
-    EventFormatVersions,
+    EventFormatVersion,
     RoomVersion,
 )
 from synapse.crypto.event_signing import add_hashes_and_signatures
@@ -137,7 +137,7 @@ class EventBuilder:
         # The types of auth/prev events changes between event versions.
         prev_events: Union[List[str], List[Tuple[str, Dict[str, str]]]]
         auth_events: Union[List[str], List[Tuple[str, Dict[str, str]]]]
-        if format_version == EventFormatVersions.ROOM_V1_V2:
+        if format_version == EventFormatVersion.ROOM_V1_V2:
             auth_events = await self._store.add_event_hashes(auth_event_ids)
             prev_events = await self._store.add_event_hashes(prev_event_ids)
         else:
@@ -253,7 +253,7 @@ def create_local_event_from_event_dict(
 
     time_now = int(clock.time_msec())
 
-    if format_version == EventFormatVersions.ROOM_V1_V2:
+    if format_version == EventFormatVersion.ROOM_V1_V2:
         event_dict["event_id"] = _create_event_id(clock, hostname)
 
     event_dict["origin"] = hostname
diff --git a/synapse/events/validator.py b/synapse/events/validator.py
index a6f0104396..f5ebf2a3d7 100644
--- a/synapse/events/validator.py
+++ b/synapse/events/validator.py
@@ -18,7 +18,7 @@ import jsonschema
 
 from synapse.api.constants import MAX_ALIAS_LENGTH, EventTypes, Membership
 from synapse.api.errors import Codes, SynapseError
-from synapse.api.room_versions import EventFormatVersions
+from synapse.api.room_versions import EventFormatVersion
 from synapse.config.homeserver import HomeServerConfig
 from synapse.events import EventBase
 from synapse.events.builder import EventBuilder
@@ -45,7 +45,7 @@ class EventValidator:
         """
         self.validate_builder(event)
 
-        if event.format_version == EventFormatVersions.ROOM_V1_V2:
+        if event.format_version == EventFormatVersion.ROOM_V1_V2:
             EventID.from_string(event.event_id)
 
         required = [
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py
index abe2c1971a..5f0b7c6c12 100644
--- a/synapse/federation/federation_base.py
+++ b/synapse/federation/federation_base.py
@@ -17,7 +17,7 @@ from typing import TYPE_CHECKING
 
 from synapse.api.constants import MAX_DEPTH, EventContentFields, EventTypes, Membership
 from synapse.api.errors import Codes, SynapseError
-from synapse.api.room_versions import EventFormatVersions, RoomVersion
+from synapse.api.room_versions import EventFormatVersion, RoomVersion
 from synapse.crypto.event_signing import check_event_content_hash
 from synapse.crypto.keyring import Keyring
 from synapse.events import EventBase, make_event_from_dict
@@ -194,7 +194,7 @@ async def _check_sigs_on_pdu(
     # event id's domain (normally only the case for joins/leaves), and add additional
     # checks. Only do this if the room version has a concept of event ID domain
     # (ie, the room version uses old-style non-hash event IDs).
-    if room_version.event_format == EventFormatVersions.ROOM_V1_V2:
+    if room_version.event_format == EventFormatVersion.ROOM_V1_V2:
         event_domain = get_domain_from_id(pdu.event_id)
         if event_domain != sender_domain:
             try:
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py
index 4a4289ee7c..8f3915d92a 100644
--- a/synapse/federation/federation_client.py
+++ b/synapse/federation/federation_client.py
@@ -49,7 +49,7 @@ from synapse.api.errors import (
 )
 from synapse.api.room_versions import (
     KNOWN_ROOM_VERSIONS,
-    EventFormatVersions,
+    EventFormatVersion,
     RoomVersion,
     RoomVersions,
 )
@@ -1190,7 +1190,7 @@ class FederationClient(FederationBase):
             # Otherwise, consider it a legitimate error and raise.
             err = e.to_synapse_error()
             if self._is_unknown_endpoint(e, err):
-                if room_version.event_format != EventFormatVersions.ROOM_V1_V2:
+                if room_version.event_format != EventFormatVersion.ROOM_V1_V2:
                     raise SynapseError(
                         400,
                         "User's homeserver does not support this room version",
diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py
index ca47a22bf1..9eb541f5c1 100644
--- a/synapse/storage/databases/main/event_federation.py
+++ b/synapse/storage/databases/main/event_federation.py
@@ -31,7 +31,7 @@ from prometheus_client import Counter, Gauge
 
 from synapse.api.constants import MAX_DEPTH, EventTypes
 from synapse.api.errors import StoreError
-from synapse.api.room_versions import EventFormatVersions, RoomVersion
+from synapse.api.room_versions import EventFormatVersion, RoomVersion
 from synapse.events import EventBase, make_event_from_dict
 from synapse.logging.opentracing import tag_args, trace
 from synapse.metrics.background_process_metrics import wrap_as_background_process
@@ -1608,7 +1608,7 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
                 logger.info("Invalid prev_events for %s", event_id)
                 continue
 
-            if room_version.event_format == EventFormatVersions.ROOM_V1_V2:
+            if room_version.event_format == EventFormatVersion.ROOM_V1_V2:
                 for prev_event_tuple in prev_events:
                     if (
                         not isinstance(prev_event_tuple, list)
diff --git a/synapse/storage/databases/main/events_worker.py b/synapse/storage/databases/main/events_worker.py
index 4566f505d8..54e2260892 100644
--- a/synapse/storage/databases/main/events_worker.py
+++ b/synapse/storage/databases/main/events_worker.py
@@ -42,7 +42,7 @@ from synapse.api.constants import EventTypes
 from synapse.api.errors import NotFoundError, SynapseError
 from synapse.api.room_versions import (
     KNOWN_ROOM_VERSIONS,
-    EventFormatVersions,
+    EventFormatVersion,
     RoomVersion,
     RoomVersions,
 )
@@ -147,7 +147,7 @@ class _EventRow:
     stream_ordering: int
     json: str
     internal_metadata: str
-    format_version: Optional[EventFormatVersions]
+    format_version: Optional[EventFormatVersion]
     room_version_id: Optional[str]
     rejected_reason: Optional[str]
     redactions: List[str]
@@ -1160,7 +1160,7 @@ class EventsWorkerStore(SQLBaseStore):
             if format_version is None:
                 # This means that we stored the event before we had the concept
                 # of a event format version, so it must be a V1 event.
-                format_version = EventFormatVersions.ROOM_V1_V2
+                format_version = EventFormatVersion.ROOM_V1_V2
 
             room_version_id = row.room_version_id
 
@@ -1190,10 +1190,10 @@ class EventsWorkerStore(SQLBaseStore):
                 #
                 # So, the following approximations should be adequate.
 
-                if format_version == EventFormatVersions.ROOM_V1_V2:
+                if format_version == EventFormatVersion.ROOM_V1_V2:
                     # if it's event format v1 then it must be room v1 or v2
                     room_version = RoomVersions.V1
-                elif format_version == EventFormatVersions.ROOM_V3:
+                elif format_version == EventFormatVersion.ROOM_V3:
                     # if it's event format v2 then it must be room v3
                     room_version = RoomVersions.V3
                 else:
@@ -1341,7 +1341,7 @@ class EventsWorkerStore(SQLBaseStore):
                     json=row[3],
                     # TODO is this the best way to do it?
                     format_version=(
-                        EventFormatVersions(row[4]) if row[4] is not None else None
+                        EventFormatVersion(row[4]) if row[4] is not None else None
                     ),
                     room_version_id=row[5],
                     rejected_reason=row[6],