2019-04-01 11:24:38 +02:00
|
|
|
# Copyright 2019 New Vector Ltd
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2019-10-02 14:29:01 +02:00
|
|
|
|
2022-12-13 14:19:19 +01:00
|
|
|
from typing import Callable, Dict, Optional, Tuple
|
2019-10-02 14:29:01 +02:00
|
|
|
|
2019-04-01 11:24:38 +02:00
|
|
|
import attr
|
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class EventFormatVersions:
|
2019-04-01 11:24:38 +02:00
|
|
|
"""This is an internal enum for tracking the version of the event format,
|
2022-09-07 12:08:20 +02:00
|
|
|
independently of the room version.
|
|
|
|
|
|
|
|
To reduce confusion, the event format versions are named after the room
|
|
|
|
versions that they were used or introduced in.
|
|
|
|
The concept of an 'event format version' is specific to Synapse (the
|
|
|
|
specification does not mention this term.)
|
2019-04-01 11:24:38 +02:00
|
|
|
"""
|
2019-06-20 11:32:02 +02:00
|
|
|
|
2022-09-07 12:08:20 +02:00
|
|
|
ROOM_V1_V2 = 1 # $id:server event id format: used for room v1 and v2
|
|
|
|
ROOM_V3 = 2 # MSC1659-style $hash event id format: used for room v3
|
|
|
|
ROOM_V4_PLUS = 3 # MSC1884-style $hash format: introduced for room v4
|
2019-04-01 11:24:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
KNOWN_EVENT_FORMAT_VERSIONS = {
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V1_V2,
|
|
|
|
EventFormatVersions.ROOM_V3,
|
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2019-04-01 11:24:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class StateResolutionVersions:
|
2019-04-01 11:24:38 +02:00
|
|
|
"""Enum to identify the state resolution algorithms"""
|
2019-06-20 11:32:02 +02:00
|
|
|
|
|
|
|
V1 = 1 # room v1 state res
|
|
|
|
V2 = 2 # MSC1442 state res: room v2 and later
|
2019-04-01 11:24:38 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class RoomDisposition:
|
2019-04-01 11:24:38 +02:00
|
|
|
STABLE = "stable"
|
|
|
|
UNSTABLE = "unstable"
|
|
|
|
|
|
|
|
|
2022-11-29 01:22:34 +01:00
|
|
|
class PushRuleRoomFlag:
|
|
|
|
"""Enum for listing possible MSC3931 room version feature flags, for push rules"""
|
|
|
|
|
|
|
|
# MSC3932: Room version supports MSC1767 Extensible Events.
|
|
|
|
EXTENSIBLE_EVENTS = "org.matrix.msc3932.extensible_events"
|
|
|
|
|
|
|
|
|
2022-01-13 14:49:28 +01:00
|
|
|
@attr.s(slots=True, frozen=True, auto_attribs=True)
|
2020-09-04 12:54:56 +02:00
|
|
|
class RoomVersion:
|
2019-04-01 11:24:38 +02:00
|
|
|
"""An object which describes the unique attributes of a room version."""
|
|
|
|
|
2022-01-13 14:49:28 +01:00
|
|
|
identifier: str # the identifier for this version
|
|
|
|
disposition: str # one of the RoomDispositions
|
|
|
|
event_format: int # one of the EventFormatVersions
|
|
|
|
state_res: int # one of the StateResolutionVersions
|
|
|
|
enforce_key_validity: bool
|
2019-04-01 11:24:38 +02:00
|
|
|
|
2021-06-09 20:39:51 +02:00
|
|
|
# Before MSC2432, m.room.aliases had special auth rules and redaction rules
|
2022-01-13 14:49:28 +01:00
|
|
|
special_case_aliases_auth: bool
|
2020-05-14 19:24:01 +02:00
|
|
|
# Strictly enforce canonicaljson, do not allow:
|
|
|
|
# * Integers outside the range of [-2 ^ 53 + 1, 2 ^ 53 - 1]
|
|
|
|
# * Floats
|
|
|
|
# * NaN, Infinity, -Infinity
|
2022-01-13 14:49:28 +01:00
|
|
|
strict_canonicaljson: bool
|
2021-01-05 13:41:48 +01:00
|
|
|
# MSC2209: Check 'notifications' key while verifying
|
2020-05-14 18:38:17 +02:00
|
|
|
# m.room.power_levels auth rules.
|
2022-01-13 14:49:28 +01:00
|
|
|
limit_notifications_power_levels: bool
|
2023-04-06 22:26:28 +02:00
|
|
|
# MSC2175: No longer include the creator in m.room.create events.
|
|
|
|
msc2175_implicit_room_creator: bool
|
2023-04-13 15:47:07 +02:00
|
|
|
# MSC2174/MSC2176: Apply updated redaction rules algorithm, move redacts to
|
|
|
|
# content property.
|
2022-01-13 14:49:28 +01:00
|
|
|
msc2176_redaction_rules: bool
|
2021-03-31 22:39:08 +02:00
|
|
|
# MSC3083: Support the 'restricted' join_rule.
|
2022-01-13 14:49:28 +01:00
|
|
|
msc3083_join_rules: bool
|
2021-09-03 18:51:15 +02:00
|
|
|
# MSC3375: Support for the proper redaction rules for MSC3083. This mustn't
|
|
|
|
# be enabled if MSC3083 is not.
|
2022-01-13 14:49:28 +01:00
|
|
|
msc3375_redaction_rules: bool
|
2021-06-09 20:39:51 +02:00
|
|
|
# MSC2403: Allows join_rules to be set to 'knock', changes auth rules to allow sending
|
|
|
|
# m.room.membership event with membership 'knock'.
|
2022-01-13 14:49:28 +01:00
|
|
|
msc2403_knocking: bool
|
2023-05-15 14:58:09 +02:00
|
|
|
# MSC3389: Protect relation information from redaction.
|
|
|
|
msc3389_relation_redactions: bool
|
2022-05-17 12:41:39 +02:00
|
|
|
# MSC3787: Adds support for a `knock_restricted` join rule, mixing concepts of
|
|
|
|
# knocks and restricted join rules into the same join condition.
|
|
|
|
msc3787_knock_restricted_join_rule: bool
|
2022-07-13 20:36:02 +02:00
|
|
|
# MSC3667: Enforce integer power levels
|
|
|
|
msc3667_int_only_power_levels: bool
|
2023-05-15 21:02:24 +02:00
|
|
|
# MSC3821: Do not redact the third_party_invite content field for membership events.
|
|
|
|
msc3821_redaction_rules: bool
|
2022-11-29 00:29:53 +01:00
|
|
|
# MSC3931: Adds a push rule condition for "room version feature flags", making
|
|
|
|
# some push rules room version dependent. Note that adding a flag to this list
|
|
|
|
# is not enough to mark it "supported": the push rule evaluator also needs to
|
|
|
|
# support the flag. Unknown flags are ignored by the evaluator, making conditions
|
|
|
|
# fail if used.
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features: Tuple[str, ...] # values from PushRuleRoomFlag
|
2023-04-05 20:42:46 +02:00
|
|
|
# MSC3989: Redact the origin field.
|
|
|
|
msc3989_redaction_rules: bool
|
2020-01-27 17:14:54 +01:00
|
|
|
|
2019-04-01 11:24:38 +02:00
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class RoomVersions:
|
2019-04-01 11:24:38 +02:00
|
|
|
V1 = RoomVersion(
|
|
|
|
"1",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V1_V2,
|
2019-04-01 11:24:38 +02:00
|
|
|
StateResolutionVersions.V1,
|
2019-06-05 11:38:25 +02:00
|
|
|
enforce_key_validity=False,
|
2020-01-27 17:14:54 +01:00
|
|
|
special_case_aliases_auth=True,
|
2020-05-14 19:24:01 +02:00
|
|
|
strict_canonicaljson=False,
|
2020-05-14 18:38:17 +02:00
|
|
|
limit_notifications_power_levels=False,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
msc2176_redaction_rules=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
msc2403_knocking=False,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2019-04-01 11:24:38 +02:00
|
|
|
)
|
|
|
|
V2 = RoomVersion(
|
|
|
|
"2",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V1_V2,
|
2019-04-01 11:24:38 +02:00
|
|
|
StateResolutionVersions.V2,
|
2019-06-05 11:38:25 +02:00
|
|
|
enforce_key_validity=False,
|
2020-01-27 17:14:54 +01:00
|
|
|
special_case_aliases_auth=True,
|
2020-05-14 19:24:01 +02:00
|
|
|
strict_canonicaljson=False,
|
2020-05-14 18:38:17 +02:00
|
|
|
limit_notifications_power_levels=False,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
msc2176_redaction_rules=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
msc2403_knocking=False,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2019-04-01 11:24:38 +02:00
|
|
|
)
|
|
|
|
V3 = RoomVersion(
|
|
|
|
"3",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V3,
|
2019-04-01 11:24:38 +02:00
|
|
|
StateResolutionVersions.V2,
|
2019-06-05 11:38:25 +02:00
|
|
|
enforce_key_validity=False,
|
2020-01-27 17:14:54 +01:00
|
|
|
special_case_aliases_auth=True,
|
2020-05-14 19:24:01 +02:00
|
|
|
strict_canonicaljson=False,
|
2020-05-14 18:38:17 +02:00
|
|
|
limit_notifications_power_levels=False,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
msc2176_redaction_rules=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
msc2403_knocking=False,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2019-04-01 11:24:38 +02:00
|
|
|
)
|
2019-05-21 17:22:54 +02:00
|
|
|
V4 = RoomVersion(
|
|
|
|
"4",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2019-05-20 16:54:42 +02:00
|
|
|
StateResolutionVersions.V2,
|
2019-06-05 11:38:25 +02:00
|
|
|
enforce_key_validity=False,
|
2020-01-27 17:14:54 +01:00
|
|
|
special_case_aliases_auth=True,
|
2020-05-14 19:24:01 +02:00
|
|
|
strict_canonicaljson=False,
|
2020-05-14 18:38:17 +02:00
|
|
|
limit_notifications_power_levels=False,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
msc2176_redaction_rules=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
msc2403_knocking=False,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2019-06-05 11:38:25 +02:00
|
|
|
)
|
2019-06-05 11:58:51 +02:00
|
|
|
V5 = RoomVersion(
|
|
|
|
"5",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2019-06-05 11:38:25 +02:00
|
|
|
StateResolutionVersions.V2,
|
2019-06-05 11:58:51 +02:00
|
|
|
enforce_key_validity=True,
|
2020-01-27 17:14:54 +01:00
|
|
|
special_case_aliases_auth=True,
|
2020-05-14 19:24:01 +02:00
|
|
|
strict_canonicaljson=False,
|
2020-05-14 18:38:17 +02:00
|
|
|
limit_notifications_power_levels=False,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
msc2176_redaction_rules=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
msc2403_knocking=False,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2020-01-27 17:14:54 +01:00
|
|
|
)
|
2020-05-15 15:30:10 +02:00
|
|
|
V6 = RoomVersion(
|
|
|
|
"6",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2020-01-27 17:14:54 +01:00
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
2020-03-09 13:58:25 +01:00
|
|
|
special_case_aliases_auth=False,
|
2020-05-14 19:24:01 +02:00
|
|
|
strict_canonicaljson=True,
|
2020-05-14 18:38:17 +02:00
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
msc2176_redaction_rules=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
msc2403_knocking=False,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
)
|
|
|
|
MSC2176 = RoomVersion(
|
|
|
|
"org.matrix.msc2176",
|
|
|
|
RoomDisposition.UNSTABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2021-01-05 13:41:48 +01:00
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-01-05 13:41:48 +01:00
|
|
|
msc2176_redaction_rules=True,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
msc2403_knocking=False,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
)
|
2021-08-09 10:46:39 +02:00
|
|
|
V7 = RoomVersion(
|
|
|
|
"7",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2021-03-31 22:39:08 +02:00
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-03-31 22:39:08 +02:00
|
|
|
msc2176_redaction_rules=False,
|
2021-08-09 10:46:39 +02:00
|
|
|
msc3083_join_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
2021-08-09 10:46:39 +02:00
|
|
|
msc2403_knocking=True,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2021-08-10 03:23:31 +02:00
|
|
|
)
|
|
|
|
V8 = RoomVersion(
|
|
|
|
"8",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2021-08-10 03:23:31 +02:00
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-08-10 03:23:31 +02:00
|
|
|
msc2176_redaction_rules=False,
|
|
|
|
msc3083_join_rules=True,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc3375_redaction_rules=False,
|
|
|
|
msc2403_knocking=True,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
)
|
|
|
|
V9 = RoomVersion(
|
|
|
|
"9",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2021-09-03 18:51:15 +02:00
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2021-09-03 18:51:15 +02:00
|
|
|
msc2176_redaction_rules=False,
|
|
|
|
msc3083_join_rules=True,
|
|
|
|
msc3375_redaction_rules=True,
|
2021-08-10 03:23:31 +02:00
|
|
|
msc2403_knocking=True,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2021-06-09 20:39:51 +02:00
|
|
|
)
|
2022-05-17 12:41:39 +02:00
|
|
|
MSC3787 = RoomVersion(
|
|
|
|
"org.matrix.msc3787",
|
|
|
|
RoomDisposition.UNSTABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2022-05-17 12:41:39 +02:00
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc2176_redaction_rules=False,
|
|
|
|
msc3083_join_rules=True,
|
|
|
|
msc3375_redaction_rules=True,
|
|
|
|
msc2403_knocking=True,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-05-17 12:41:39 +02:00
|
|
|
msc3787_knock_restricted_join_rule=True,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3667_int_only_power_levels=False,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
|
|
|
msc3931_push_features=(),
|
|
|
|
msc3989_redaction_rules=False,
|
|
|
|
)
|
|
|
|
MSC3821 = RoomVersion(
|
|
|
|
"org.matrix.msc3821.opt1",
|
|
|
|
RoomDisposition.UNSTABLE,
|
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
|
|
|
msc2175_implicit_room_creator=False,
|
|
|
|
msc2176_redaction_rules=False,
|
|
|
|
msc3083_join_rules=True,
|
|
|
|
msc3375_redaction_rules=True,
|
|
|
|
msc2403_knocking=True,
|
|
|
|
msc3389_relation_redactions=False,
|
|
|
|
msc3787_knock_restricted_join_rule=False,
|
|
|
|
msc3667_int_only_power_levels=False,
|
|
|
|
msc3821_redaction_rules=True,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
)
|
|
|
|
V10 = RoomVersion(
|
|
|
|
"10",
|
|
|
|
RoomDisposition.STABLE,
|
2022-09-07 12:08:20 +02:00
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
2022-07-13 20:36:02 +02:00
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc2176_redaction_rules=False,
|
|
|
|
msc3083_join_rules=True,
|
|
|
|
msc3375_redaction_rules=True,
|
|
|
|
msc2403_knocking=True,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-07-13 20:36:02 +02:00
|
|
|
msc3787_knock_restricted_join_rule=True,
|
|
|
|
msc3667_int_only_power_levels=True,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
2019-05-20 16:54:42 +02:00
|
|
|
)
|
2022-11-29 01:22:34 +01:00
|
|
|
MSC1767v10 = RoomVersion(
|
|
|
|
# MSC1767 (Extensible Events) based on room version "10"
|
|
|
|
"org.matrix.msc1767.10",
|
|
|
|
RoomDisposition.UNSTABLE,
|
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2022-11-29 01:22:34 +01:00
|
|
|
msc2176_redaction_rules=False,
|
|
|
|
msc3083_join_rules=True,
|
|
|
|
msc3375_redaction_rules=True,
|
|
|
|
msc2403_knocking=True,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2022-11-29 01:22:34 +01:00
|
|
|
msc3787_knock_restricted_join_rule=True,
|
|
|
|
msc3667_int_only_power_levels=True,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2022-12-13 14:19:19 +01:00
|
|
|
msc3931_push_features=(PushRuleRoomFlag.EXTENSIBLE_EVENTS,),
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3989_redaction_rules=False,
|
|
|
|
)
|
|
|
|
MSC3989 = RoomVersion(
|
|
|
|
"org.matrix.msc3989",
|
|
|
|
RoomDisposition.UNSTABLE,
|
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
2023-04-06 22:26:28 +02:00
|
|
|
msc2175_implicit_room_creator=False,
|
2023-04-05 20:42:46 +02:00
|
|
|
msc2176_redaction_rules=False,
|
|
|
|
msc3083_join_rules=True,
|
|
|
|
msc3375_redaction_rules=True,
|
|
|
|
msc2403_knocking=True,
|
2023-05-15 14:58:09 +02:00
|
|
|
msc3389_relation_redactions=False,
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3787_knock_restricted_join_rule=True,
|
|
|
|
msc3667_int_only_power_levels=True,
|
2023-05-15 21:02:24 +02:00
|
|
|
msc3821_redaction_rules=False,
|
2023-04-05 20:42:46 +02:00
|
|
|
msc3931_push_features=(),
|
|
|
|
msc3989_redaction_rules=True,
|
2022-11-29 01:22:34 +01:00
|
|
|
)
|
2023-05-26 13:46:13 +02:00
|
|
|
MSC3820opt2 = RoomVersion(
|
|
|
|
# Based upon v10
|
|
|
|
"org.matrix.msc3820.opt2",
|
|
|
|
RoomDisposition.UNSTABLE,
|
|
|
|
EventFormatVersions.ROOM_V4_PLUS,
|
|
|
|
StateResolutionVersions.V2,
|
|
|
|
enforce_key_validity=True,
|
|
|
|
special_case_aliases_auth=False,
|
|
|
|
strict_canonicaljson=True,
|
|
|
|
limit_notifications_power_levels=True,
|
|
|
|
msc2175_implicit_room_creator=True, # Used by MSC3820
|
|
|
|
msc2176_redaction_rules=True, # Used by MSC3820
|
|
|
|
msc3083_join_rules=True,
|
|
|
|
msc3375_redaction_rules=True,
|
|
|
|
msc2403_knocking=True,
|
|
|
|
msc3389_relation_redactions=False,
|
|
|
|
msc3787_knock_restricted_join_rule=True,
|
|
|
|
msc3667_int_only_power_levels=True,
|
|
|
|
msc3821_redaction_rules=True, # Used by MSC3820
|
|
|
|
msc3931_push_features=(),
|
|
|
|
msc3989_redaction_rules=True, # Used by MSC3820
|
|
|
|
)
|
2019-04-01 11:24:38 +02:00
|
|
|
|
|
|
|
|
2021-07-15 12:02:43 +02:00
|
|
|
KNOWN_ROOM_VERSIONS: Dict[str, RoomVersion] = {
|
2019-06-20 11:32:02 +02:00
|
|
|
v.identifier: v
|
|
|
|
for v in (
|
2019-04-01 11:24:38 +02:00
|
|
|
RoomVersions.V1,
|
|
|
|
RoomVersions.V2,
|
|
|
|
RoomVersions.V3,
|
2019-05-21 17:22:54 +02:00
|
|
|
RoomVersions.V4,
|
2019-06-05 11:58:51 +02:00
|
|
|
RoomVersions.V5,
|
2020-05-15 15:30:10 +02:00
|
|
|
RoomVersions.V6,
|
2021-01-05 13:41:48 +01:00
|
|
|
RoomVersions.MSC2176,
|
2021-06-15 13:45:14 +02:00
|
|
|
RoomVersions.V7,
|
2021-08-09 10:46:39 +02:00
|
|
|
RoomVersions.V8,
|
2021-09-03 18:51:15 +02:00
|
|
|
RoomVersions.V9,
|
2022-05-17 12:41:39 +02:00
|
|
|
RoomVersions.MSC3787,
|
2022-07-13 20:36:02 +02:00
|
|
|
RoomVersions.V10,
|
2023-04-05 20:42:46 +02:00
|
|
|
RoomVersions.MSC3989,
|
2023-05-26 20:05:24 +02:00
|
|
|
RoomVersions.MSC3820opt2,
|
2019-04-01 11:24:38 +02:00
|
|
|
)
|
2021-07-20 13:59:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@attr.s(slots=True, frozen=True, auto_attribs=True)
|
|
|
|
class RoomVersionCapability:
|
|
|
|
"""An object which describes the unique attributes of a room version."""
|
|
|
|
|
|
|
|
identifier: str # the identifier for this capability
|
|
|
|
preferred_version: Optional[RoomVersion]
|
|
|
|
support_check_lambda: Callable[[RoomVersion], bool]
|
|
|
|
|
|
|
|
|
|
|
|
MSC3244_CAPABILITIES = {
|
|
|
|
cap.identifier: {
|
|
|
|
"preferred": cap.preferred_version.identifier
|
|
|
|
if cap.preferred_version is not None
|
|
|
|
else None,
|
|
|
|
"support": [
|
|
|
|
v.identifier
|
|
|
|
for v in KNOWN_ROOM_VERSIONS.values()
|
|
|
|
if cap.support_check_lambda(v)
|
|
|
|
],
|
|
|
|
}
|
|
|
|
for cap in (
|
|
|
|
RoomVersionCapability(
|
|
|
|
"knock",
|
|
|
|
RoomVersions.V7,
|
|
|
|
lambda room_version: room_version.msc2403_knocking,
|
|
|
|
),
|
|
|
|
RoomVersionCapability(
|
|
|
|
"restricted",
|
2021-09-09 13:37:33 +02:00
|
|
|
RoomVersions.V9,
|
2021-07-20 13:59:23 +02:00
|
|
|
lambda room_version: room_version.msc3083_join_rules,
|
|
|
|
),
|
|
|
|
)
|
2021-07-15 12:02:43 +02:00
|
|
|
}
|