mirror of
https://github.com/element-hq/synapse
synced 2024-09-17 20:05:10 +00:00
Remove the 's' from EventFormatVersions
This commit is contained in:
parent
09f29d5985
commit
f6b3884f36
12 changed files with 54 additions and 54 deletions
|
@ -17,7 +17,7 @@ from typing import Callable, Dict, Optional
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
|
|
||||||
class EventFormatVersions(Enum):
|
class EventFormatVersion(Enum):
|
||||||
"""This is an internal enum for tracking the version of the event format,
|
"""This is an internal enum for tracking the version of the event format,
|
||||||
independently of the room version.
|
independently of the room version.
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ class EventFormatVersions(Enum):
|
||||||
|
|
||||||
|
|
||||||
KNOWN_EVENT_FORMAT_VERSIONS = {
|
KNOWN_EVENT_FORMAT_VERSIONS = {
|
||||||
EventFormatVersions.ROOM_V1_V2,
|
EventFormatVersion.ROOM_V1_V2,
|
||||||
EventFormatVersions.ROOM_V3,
|
EventFormatVersion.ROOM_V3,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class RoomVersion:
|
||||||
|
|
||||||
identifier: str # the identifier for this version
|
identifier: str # the identifier for this version
|
||||||
disposition: str # one of the RoomDispositions
|
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
|
state_res: int # one of the StateResolutionVersions
|
||||||
enforce_key_validity: bool
|
enforce_key_validity: bool
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class RoomVersions:
|
||||||
V1 = RoomVersion(
|
V1 = RoomVersion(
|
||||||
"1",
|
"1",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V1_V2,
|
EventFormatVersion.ROOM_V1_V2,
|
||||||
StateResolutionVersions.V1,
|
StateResolutionVersions.V1,
|
||||||
enforce_key_validity=False,
|
enforce_key_validity=False,
|
||||||
special_case_aliases_auth=True,
|
special_case_aliases_auth=True,
|
||||||
|
@ -115,7 +115,7 @@ class RoomVersions:
|
||||||
V2 = RoomVersion(
|
V2 = RoomVersion(
|
||||||
"2",
|
"2",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V1_V2,
|
EventFormatVersion.ROOM_V1_V2,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=False,
|
enforce_key_validity=False,
|
||||||
special_case_aliases_auth=True,
|
special_case_aliases_auth=True,
|
||||||
|
@ -133,7 +133,7 @@ class RoomVersions:
|
||||||
V3 = RoomVersion(
|
V3 = RoomVersion(
|
||||||
"3",
|
"3",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V3,
|
EventFormatVersion.ROOM_V3,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=False,
|
enforce_key_validity=False,
|
||||||
special_case_aliases_auth=True,
|
special_case_aliases_auth=True,
|
||||||
|
@ -151,7 +151,7 @@ class RoomVersions:
|
||||||
V4 = RoomVersion(
|
V4 = RoomVersion(
|
||||||
"4",
|
"4",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=False,
|
enforce_key_validity=False,
|
||||||
special_case_aliases_auth=True,
|
special_case_aliases_auth=True,
|
||||||
|
@ -169,7 +169,7 @@ class RoomVersions:
|
||||||
V5 = RoomVersion(
|
V5 = RoomVersion(
|
||||||
"5",
|
"5",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=True,
|
special_case_aliases_auth=True,
|
||||||
|
@ -187,7 +187,7 @@ class RoomVersions:
|
||||||
V6 = RoomVersion(
|
V6 = RoomVersion(
|
||||||
"6",
|
"6",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
@ -205,7 +205,7 @@ class RoomVersions:
|
||||||
MSC2176 = RoomVersion(
|
MSC2176 = RoomVersion(
|
||||||
"org.matrix.msc2176",
|
"org.matrix.msc2176",
|
||||||
RoomDisposition.UNSTABLE,
|
RoomDisposition.UNSTABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
@ -223,7 +223,7 @@ class RoomVersions:
|
||||||
V7 = RoomVersion(
|
V7 = RoomVersion(
|
||||||
"7",
|
"7",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
@ -241,7 +241,7 @@ class RoomVersions:
|
||||||
V8 = RoomVersion(
|
V8 = RoomVersion(
|
||||||
"8",
|
"8",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
@ -259,7 +259,7 @@ class RoomVersions:
|
||||||
V9 = RoomVersion(
|
V9 = RoomVersion(
|
||||||
"9",
|
"9",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
@ -277,7 +277,7 @@ class RoomVersions:
|
||||||
MSC3787 = RoomVersion(
|
MSC3787 = RoomVersion(
|
||||||
"org.matrix.msc3787",
|
"org.matrix.msc3787",
|
||||||
RoomDisposition.UNSTABLE,
|
RoomDisposition.UNSTABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
@ -295,7 +295,7 @@ class RoomVersions:
|
||||||
V10 = RoomVersion(
|
V10 = RoomVersion(
|
||||||
"10",
|
"10",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
@ -313,7 +313,7 @@ class RoomVersions:
|
||||||
MSC2716v4 = RoomVersion(
|
MSC2716v4 = RoomVersion(
|
||||||
"org.matrix.msc2716v4",
|
"org.matrix.msc2716v4",
|
||||||
RoomDisposition.UNSTABLE,
|
RoomDisposition.UNSTABLE,
|
||||||
EventFormatVersions.ROOM_V4_PLUS,
|
EventFormatVersion.ROOM_V4_PLUS,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
special_case_aliases_auth=False,
|
special_case_aliases_auth=False,
|
||||||
|
|
|
@ -39,7 +39,7 @@ from synapse.api.errors import (
|
||||||
)
|
)
|
||||||
from synapse.api.room_versions import (
|
from synapse.api.room_versions import (
|
||||||
KNOWN_ROOM_VERSIONS,
|
KNOWN_ROOM_VERSIONS,
|
||||||
EventFormatVersions,
|
EventFormatVersion,
|
||||||
RoomVersion,
|
RoomVersion,
|
||||||
)
|
)
|
||||||
from synapse.storage.databases.main.events_worker import EventRedactBehaviour
|
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:
|
if not is_invite_via_3pid:
|
||||||
raise AuthError(403, "Event not signed by sender's server")
|
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.
|
# Only older room versions have event IDs to check.
|
||||||
event_id_domain = get_domain_from_id(event.event_id)
|
event_id_domain = get_domain_from_id(event.event_id)
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ def check_redaction(
|
||||||
if user_level >= redact_level:
|
if user_level >= redact_level:
|
||||||
return False
|
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)
|
redacter_domain = get_domain_from_id(event.event_id)
|
||||||
if not isinstance(event.redacts, str):
|
if not isinstance(event.redacts, str):
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -38,7 +38,7 @@ from typing_extensions import Literal
|
||||||
from unpaddedbase64 import encode_base64
|
from unpaddedbase64 import encode_base64
|
||||||
|
|
||||||
from synapse.api.constants import RelationTypes
|
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.types import JsonDict, RoomStreamToken
|
||||||
from synapse.util.caches import intern_dict
|
from synapse.util.caches import intern_dict
|
||||||
from synapse.util.frozenutils import freeze
|
from synapse.util.frozenutils import freeze
|
||||||
|
@ -293,7 +293,7 @@ class _EventInternalMetadata:
|
||||||
class EventBase(metaclass=abc.ABCMeta):
|
class EventBase(metaclass=abc.ABCMeta):
|
||||||
@property
|
@property
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def format_version(self) -> EventFormatVersions:
|
def format_version(self) -> EventFormatVersion:
|
||||||
"""The EventFormatVersion implemented by this event"""
|
"""The EventFormatVersion implemented by this event"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ class EventBase(metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
|
|
||||||
class FrozenEvent(EventBase):
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -490,7 +490,7 @@ class FrozenEvent(EventBase):
|
||||||
|
|
||||||
|
|
||||||
class FrozenEventV2(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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -567,7 +567,7 @@ class FrozenEventV2(EventBase):
|
||||||
class FrozenEventV3(FrozenEventV2):
|
class FrozenEventV3(FrozenEventV2):
|
||||||
"""FrozenEventV3, which differs from FrozenEventV2 only in the event_id format"""
|
"""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
|
@property
|
||||||
def event_id(self) -> str:
|
def event_id(self) -> str:
|
||||||
|
@ -584,7 +584,7 @@ class FrozenEventV3(FrozenEventV2):
|
||||||
|
|
||||||
|
|
||||||
def _event_type_from_format_version(
|
def _event_type_from_format_version(
|
||||||
format_version: EventFormatVersions,
|
format_version: EventFormatVersion,
|
||||||
) -> Type[Union[FrozenEvent, FrozenEventV2, FrozenEventV3]]:
|
) -> Type[Union[FrozenEvent, FrozenEventV2, FrozenEventV3]]:
|
||||||
"""Returns the python type to use to construct an Event object for the
|
"""Returns the python type to use to construct an Event object for the
|
||||||
given event format version.
|
given event format version.
|
||||||
|
@ -597,11 +597,11 @@ def _event_type_from_format_version(
|
||||||
`FrozenEvent`
|
`FrozenEvent`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if format_version == EventFormatVersions.ROOM_V1_V2:
|
if format_version == EventFormatVersion.ROOM_V1_V2:
|
||||||
return FrozenEvent
|
return FrozenEvent
|
||||||
elif format_version == EventFormatVersions.ROOM_V3:
|
elif format_version == EventFormatVersion.ROOM_V3:
|
||||||
return FrozenEventV2
|
return FrozenEventV2
|
||||||
elif format_version == EventFormatVersions.ROOM_V4_PLUS:
|
elif format_version == EventFormatVersion.ROOM_V4_PLUS:
|
||||||
return FrozenEventV3
|
return FrozenEventV3
|
||||||
else:
|
else:
|
||||||
raise Exception("No event format %r" % (format_version,))
|
raise Exception("No event format %r" % (format_version,))
|
||||||
|
|
|
@ -20,7 +20,7 @@ from signedjson.types import SigningKey
|
||||||
from synapse.api.constants import MAX_DEPTH
|
from synapse.api.constants import MAX_DEPTH
|
||||||
from synapse.api.room_versions import (
|
from synapse.api.room_versions import (
|
||||||
KNOWN_EVENT_FORMAT_VERSIONS,
|
KNOWN_EVENT_FORMAT_VERSIONS,
|
||||||
EventFormatVersions,
|
EventFormatVersion,
|
||||||
RoomVersion,
|
RoomVersion,
|
||||||
)
|
)
|
||||||
from synapse.crypto.event_signing import add_hashes_and_signatures
|
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.
|
# The types of auth/prev events changes between event versions.
|
||||||
prev_events: Union[List[str], List[Tuple[str, Dict[str, str]]]]
|
prev_events: Union[List[str], List[Tuple[str, Dict[str, str]]]]
|
||||||
auth_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)
|
auth_events = await self._store.add_event_hashes(auth_event_ids)
|
||||||
prev_events = await self._store.add_event_hashes(prev_event_ids)
|
prev_events = await self._store.add_event_hashes(prev_event_ids)
|
||||||
else:
|
else:
|
||||||
|
@ -253,7 +253,7 @@ def create_local_event_from_event_dict(
|
||||||
|
|
||||||
time_now = int(clock.time_msec())
|
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["event_id"] = _create_event_id(clock, hostname)
|
||||||
|
|
||||||
event_dict["origin"] = hostname
|
event_dict["origin"] = hostname
|
||||||
|
|
|
@ -18,7 +18,7 @@ import jsonschema
|
||||||
|
|
||||||
from synapse.api.constants import MAX_ALIAS_LENGTH, EventTypes, Membership
|
from synapse.api.constants import MAX_ALIAS_LENGTH, EventTypes, Membership
|
||||||
from synapse.api.errors import Codes, SynapseError
|
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.config.homeserver import HomeServerConfig
|
||||||
from synapse.events import EventBase
|
from synapse.events import EventBase
|
||||||
from synapse.events.builder import EventBuilder
|
from synapse.events.builder import EventBuilder
|
||||||
|
@ -45,7 +45,7 @@ class EventValidator:
|
||||||
"""
|
"""
|
||||||
self.validate_builder(event)
|
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)
|
EventID.from_string(event.event_id)
|
||||||
|
|
||||||
required = [
|
required = [
|
||||||
|
|
|
@ -17,7 +17,7 @@ from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from synapse.api.constants import MAX_DEPTH, EventContentFields, EventTypes, Membership
|
from synapse.api.constants import MAX_DEPTH, EventContentFields, EventTypes, Membership
|
||||||
from synapse.api.errors import Codes, SynapseError
|
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.event_signing import check_event_content_hash
|
||||||
from synapse.crypto.keyring import Keyring
|
from synapse.crypto.keyring import Keyring
|
||||||
from synapse.events import EventBase, make_event_from_dict
|
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
|
# 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
|
# 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).
|
# (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)
|
event_domain = get_domain_from_id(pdu.event_id)
|
||||||
if event_domain != sender_domain:
|
if event_domain != sender_domain:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -49,7 +49,7 @@ from synapse.api.errors import (
|
||||||
)
|
)
|
||||||
from synapse.api.room_versions import (
|
from synapse.api.room_versions import (
|
||||||
KNOWN_ROOM_VERSIONS,
|
KNOWN_ROOM_VERSIONS,
|
||||||
EventFormatVersions,
|
EventFormatVersion,
|
||||||
RoomVersion,
|
RoomVersion,
|
||||||
RoomVersions,
|
RoomVersions,
|
||||||
)
|
)
|
||||||
|
@ -1190,7 +1190,7 @@ class FederationClient(FederationBase):
|
||||||
# Otherwise, consider it a legitimate error and raise.
|
# Otherwise, consider it a legitimate error and raise.
|
||||||
err = e.to_synapse_error()
|
err = e.to_synapse_error()
|
||||||
if self._is_unknown_endpoint(e, err):
|
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(
|
raise SynapseError(
|
||||||
400,
|
400,
|
||||||
"User's homeserver does not support this room version",
|
"User's homeserver does not support this room version",
|
||||||
|
|
|
@ -31,7 +31,7 @@ from prometheus_client import Counter, Gauge
|
||||||
|
|
||||||
from synapse.api.constants import MAX_DEPTH, EventTypes
|
from synapse.api.constants import MAX_DEPTH, EventTypes
|
||||||
from synapse.api.errors import StoreError
|
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.events import EventBase, make_event_from_dict
|
||||||
from synapse.logging.opentracing import tag_args, trace
|
from synapse.logging.opentracing import tag_args, trace
|
||||||
from synapse.metrics.background_process_metrics import wrap_as_background_process
|
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)
|
logger.info("Invalid prev_events for %s", event_id)
|
||||||
continue
|
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:
|
for prev_event_tuple in prev_events:
|
||||||
if (
|
if (
|
||||||
not isinstance(prev_event_tuple, list)
|
not isinstance(prev_event_tuple, list)
|
||||||
|
|
|
@ -42,7 +42,7 @@ from synapse.api.constants import EventTypes
|
||||||
from synapse.api.errors import NotFoundError, SynapseError
|
from synapse.api.errors import NotFoundError, SynapseError
|
||||||
from synapse.api.room_versions import (
|
from synapse.api.room_versions import (
|
||||||
KNOWN_ROOM_VERSIONS,
|
KNOWN_ROOM_VERSIONS,
|
||||||
EventFormatVersions,
|
EventFormatVersion,
|
||||||
RoomVersion,
|
RoomVersion,
|
||||||
RoomVersions,
|
RoomVersions,
|
||||||
)
|
)
|
||||||
|
@ -147,7 +147,7 @@ class _EventRow:
|
||||||
stream_ordering: int
|
stream_ordering: int
|
||||||
json: str
|
json: str
|
||||||
internal_metadata: str
|
internal_metadata: str
|
||||||
format_version: Optional[EventFormatVersions]
|
format_version: Optional[EventFormatVersion]
|
||||||
room_version_id: Optional[str]
|
room_version_id: Optional[str]
|
||||||
rejected_reason: Optional[str]
|
rejected_reason: Optional[str]
|
||||||
redactions: List[str]
|
redactions: List[str]
|
||||||
|
@ -1160,7 +1160,7 @@ class EventsWorkerStore(SQLBaseStore):
|
||||||
if format_version is None:
|
if format_version is None:
|
||||||
# This means that we stored the event before we had the concept
|
# This means that we stored the event before we had the concept
|
||||||
# of a event format version, so it must be a V1 event.
|
# 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
|
room_version_id = row.room_version_id
|
||||||
|
|
||||||
|
@ -1190,10 +1190,10 @@ class EventsWorkerStore(SQLBaseStore):
|
||||||
#
|
#
|
||||||
# So, the following approximations should be adequate.
|
# 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
|
# if it's event format v1 then it must be room v1 or v2
|
||||||
room_version = RoomVersions.V1
|
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
|
# if it's event format v2 then it must be room v3
|
||||||
room_version = RoomVersions.V3
|
room_version = RoomVersions.V3
|
||||||
else:
|
else:
|
||||||
|
@ -1341,7 +1341,7 @@ class EventsWorkerStore(SQLBaseStore):
|
||||||
json=row[3],
|
json=row[3],
|
||||||
# TODO is this the best way to do it?
|
# TODO is this the best way to do it?
|
||||||
format_version=(
|
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],
|
room_version_id=row[5],
|
||||||
rejected_reason=row[6],
|
rejected_reason=row[6],
|
||||||
|
|
|
@ -20,7 +20,7 @@ from twisted.enterprise.adbapi import ConnectionPool
|
||||||
from twisted.internet.defer import CancelledError, Deferred, ensureDeferred
|
from twisted.internet.defer import CancelledError, Deferred, ensureDeferred
|
||||||
from twisted.test.proto_helpers import MemoryReactor
|
from twisted.test.proto_helpers import MemoryReactor
|
||||||
|
|
||||||
from synapse.api.room_versions import EventFormatVersions, RoomVersions
|
from synapse.api.room_versions import EventFormatVersion, RoomVersions
|
||||||
from synapse.events import make_event_from_dict
|
from synapse.events import make_event_from_dict
|
||||||
from synapse.logging.context import LoggingContext
|
from synapse.logging.context import LoggingContext
|
||||||
from synapse.rest import admin
|
from synapse.rest import admin
|
||||||
|
@ -254,7 +254,7 @@ class DatabaseOutageTestCase(unittest.HomeserverTestCase):
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
"json": json.dumps(event_json),
|
"json": json.dumps(event_json),
|
||||||
"internal_metadata": "{}",
|
"internal_metadata": "{}",
|
||||||
"format_version": EventFormatVersions.ROOM_V4_PLUS,
|
"format_version": EventFormatVersion.ROOM_V4_PLUS,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,7 @@ from parameterized import parameterized
|
||||||
|
|
||||||
from synapse.api.room_versions import (
|
from synapse.api.room_versions import (
|
||||||
KNOWN_ROOM_VERSIONS,
|
KNOWN_ROOM_VERSIONS,
|
||||||
EventFormatVersions,
|
EventFormatVersion,
|
||||||
RoomVersion,
|
RoomVersion,
|
||||||
)
|
)
|
||||||
from synapse.events import _EventInternalMetadata
|
from synapse.events import _EventInternalMetadata
|
||||||
|
@ -513,7 +513,7 @@ class EventFederationWorkerStoreTestCase(tests.unittest.HomeserverTestCase):
|
||||||
|
|
||||||
def prev_event_format(prev_event_id: str) -> Union[Tuple[str, dict], str]:
|
def prev_event_format(prev_event_id: str) -> Union[Tuple[str, dict], str]:
|
||||||
"""Account for differences in prev_events format across room versions"""
|
"""Account for differences in prev_events format across room versions"""
|
||||||
if room_version.event_format == EventFormatVersions.ROOM_V1_V2:
|
if room_version.event_format == EventFormatVersion.ROOM_V1_V2:
|
||||||
return prev_event_id, {}
|
return prev_event_id, {}
|
||||||
|
|
||||||
return prev_event_id
|
return prev_event_id
|
||||||
|
|
|
@ -20,7 +20,7 @@ from parameterized import parameterized
|
||||||
from synapse import event_auth
|
from synapse import event_auth
|
||||||
from synapse.api.constants import EventContentFields
|
from synapse.api.constants import EventContentFields
|
||||||
from synapse.api.errors import AuthError, SynapseError
|
from synapse.api.errors import AuthError, SynapseError
|
||||||
from synapse.api.room_versions import EventFormatVersions, RoomVersion, RoomVersions
|
from synapse.api.room_versions import EventFormatVersion, RoomVersion, RoomVersions
|
||||||
from synapse.events import EventBase, make_event_from_dict
|
from synapse.events import EventBase, make_event_from_dict
|
||||||
from synapse.storage.databases.main.events_worker import EventRedactBehaviour
|
from synapse.storage.databases.main.events_worker import EventRedactBehaviour
|
||||||
from synapse.types import JsonDict, get_domain_from_id
|
from synapse.types import JsonDict, get_domain_from_id
|
||||||
|
@ -821,7 +821,7 @@ def _alias_event(room_version: RoomVersion, sender: str, **kwargs) -> EventBase:
|
||||||
def _build_auth_dict_for_room_version(
|
def _build_auth_dict_for_room_version(
|
||||||
room_version: RoomVersion, auth_events: Iterable[EventBase]
|
room_version: RoomVersion, auth_events: Iterable[EventBase]
|
||||||
) -> List:
|
) -> List:
|
||||||
if room_version.event_format == EventFormatVersions.ROOM_V1_V2:
|
if room_version.event_format == EventFormatVersion.ROOM_V1_V2:
|
||||||
return [(e.event_id, "not_used") for e in auth_events]
|
return [(e.event_id, "not_used") for e in auth_events]
|
||||||
else:
|
else:
|
||||||
return [e.event_id for e in auth_events]
|
return [e.event_id for e in auth_events]
|
||||||
|
@ -871,7 +871,7 @@ event_count = 0
|
||||||
|
|
||||||
def _maybe_get_event_id_dict_for_room_version(room_version: RoomVersion) -> dict:
|
def _maybe_get_event_id_dict_for_room_version(room_version: RoomVersion) -> dict:
|
||||||
"""If this room version needs it, generate an event id"""
|
"""If this room version needs it, generate an event id"""
|
||||||
if room_version.event_format != EventFormatVersions.ROOM_V1_V2:
|
if room_version.event_format != EventFormatVersion.ROOM_V1_V2:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
global event_count
|
global event_count
|
||||||
|
|
Loading…
Reference in a new issue