2016-01-07 05:26:29 +01:00
|
|
|
# Copyright 2014-2016 OpenMarket Ltd
|
2017-03-13 18:27:51 +01:00
|
|
|
# Copyright 2017 Vector Creations Ltd
|
2019-11-05 11:56:39 +01:00
|
|
|
# Copyright 2018-2019 New Vector Ltd
|
|
|
|
# Copyright 2019 The Matrix.org Foundation C.I.C.
|
2014-08-12 16:10:52 +02:00
|
|
|
#
|
|
|
|
# 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.
|
2014-08-13 04:14:34 +02:00
|
|
|
|
2014-08-12 16:10:52 +02:00
|
|
|
"""Contains constants from the specification."""
|
|
|
|
|
2023-01-27 13:27:55 +01:00
|
|
|
import enum
|
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
from typing_extensions import Final
|
|
|
|
|
2021-04-23 20:20:44 +02:00
|
|
|
# the max size of a (canonical-json-encoded) event
|
|
|
|
MAX_PDU_SIZE = 65536
|
|
|
|
|
2018-05-01 17:19:39 +02:00
|
|
|
# the "depth" field on events is limited to 2**63 - 1
|
2022-03-29 12:41:19 +02:00
|
|
|
MAX_DEPTH = 2**63 - 1
|
2018-05-01 17:19:39 +02:00
|
|
|
|
2019-05-08 18:01:30 +02:00
|
|
|
# the maximum length for a room alias is 255 characters
|
|
|
|
MAX_ALIAS_LENGTH = 255
|
|
|
|
|
2019-05-20 12:20:08 +02:00
|
|
|
# the maximum length for a user id is 255 characters
|
|
|
|
MAX_USERID_LENGTH = 255
|
|
|
|
|
2022-10-04 15:47:04 +02:00
|
|
|
# Constant value used for the pseudo-thread which is the main timeline.
|
|
|
|
MAIN_TIMELINE: Final = "main"
|
|
|
|
|
2014-08-12 16:10:52 +02:00
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class Membership:
|
2014-08-12 16:10:52 +02:00
|
|
|
|
|
|
|
"""Represents the membership states of a user in a room."""
|
2019-06-20 11:32:02 +02:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
INVITE: Final = "invite"
|
|
|
|
JOIN: Final = "join"
|
|
|
|
KNOCK: Final = "knock"
|
|
|
|
LEAVE: Final = "leave"
|
|
|
|
BAN: Final = "ban"
|
|
|
|
LIST: Final = (INVITE, JOIN, KNOCK, LEAVE, BAN)
|
2014-08-12 16:10:52 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class PresenceState:
|
2014-08-12 16:10:52 +02:00
|
|
|
"""Represents the presence state of a user."""
|
2019-06-20 11:32:02 +02:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
OFFLINE: Final = "offline"
|
|
|
|
UNAVAILABLE: Final = "unavailable"
|
|
|
|
ONLINE: Final = "online"
|
|
|
|
BUSY: Final = "org.matrix.msc3026.busy"
|
2014-08-28 11:59:15 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class JoinRules:
|
2021-11-25 17:14:23 +01:00
|
|
|
PUBLIC: Final = "public"
|
|
|
|
KNOCK: Final = "knock"
|
|
|
|
INVITE: Final = "invite"
|
|
|
|
PRIVATE: Final = "private"
|
2021-03-31 22:39:08 +02:00
|
|
|
# As defined for MSC3083.
|
2021-11-25 17:14:23 +01:00
|
|
|
RESTRICTED: Final = "restricted"
|
2022-05-17 12:41:39 +02:00
|
|
|
# As defined for MSC3787.
|
|
|
|
KNOCK_RESTRICTED: Final = "knock_restricted"
|
2014-09-15 11:23:20 +02:00
|
|
|
|
|
|
|
|
2021-06-17 18:53:27 +02:00
|
|
|
class RestrictedJoinRuleTypes:
|
|
|
|
"""Understood types for the allow rules in restricted join rules."""
|
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
ROOM_MEMBERSHIP: Final = "m.room_membership"
|
2021-06-17 18:53:27 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class LoginType:
|
2021-11-25 17:14:23 +01:00
|
|
|
PASSWORD: Final = "m.login.password"
|
|
|
|
EMAIL_IDENTITY: Final = "m.login.email.identity"
|
|
|
|
MSISDN: Final = "m.login.msisdn"
|
|
|
|
RECAPTCHA: Final = "m.login.recaptcha"
|
|
|
|
TERMS: Final = "m.login.terms"
|
|
|
|
SSO: Final = "m.login.sso"
|
|
|
|
DUMMY: Final = "m.login.dummy"
|
2022-02-04 13:15:13 +01:00
|
|
|
REGISTRATION_TOKEN: Final = "m.login.registration_token"
|
2015-04-02 18:01:29 +02:00
|
|
|
|
2014-12-03 17:07:21 +01:00
|
|
|
|
2021-04-12 16:13:55 +02:00
|
|
|
# This is used in the `type` parameter for /register when called by
|
|
|
|
# an appservice to register a new user.
|
2021-11-25 17:14:23 +01:00
|
|
|
APP_SERVICE_REGISTRATION_TYPE: Final = "m.login.application_service"
|
2021-04-12 16:13:55 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class EventTypes:
|
2021-11-25 17:14:23 +01:00
|
|
|
Member: Final = "m.room.member"
|
|
|
|
Create: Final = "m.room.create"
|
|
|
|
Tombstone: Final = "m.room.tombstone"
|
|
|
|
JoinRules: Final = "m.room.join_rules"
|
|
|
|
PowerLevels: Final = "m.room.power_levels"
|
|
|
|
Aliases: Final = "m.room.aliases"
|
|
|
|
Redaction: Final = "m.room.redaction"
|
|
|
|
ThirdPartyInvite: Final = "m.room.third_party_invite"
|
|
|
|
|
|
|
|
RoomHistoryVisibility: Final = "m.room.history_visibility"
|
|
|
|
CanonicalAlias: Final = "m.room.canonical_alias"
|
|
|
|
Encrypted: Final = "m.room.encrypted"
|
|
|
|
RoomAvatar: Final = "m.room.avatar"
|
|
|
|
RoomEncryption: Final = "m.room.encryption"
|
|
|
|
GuestAccess: Final = "m.room.guest_access"
|
2015-07-02 17:20:10 +02:00
|
|
|
|
2014-12-12 11:56:14 +01:00
|
|
|
# These are used for validation
|
2021-11-25 17:14:23 +01:00
|
|
|
Message: Final = "m.room.message"
|
|
|
|
Topic: Final = "m.room.topic"
|
|
|
|
Name: Final = "m.room.name"
|
2015-01-28 17:16:53 +01:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
ServerACL: Final = "m.room.server_acl"
|
|
|
|
Pinned: Final = "m.room.pinned_events"
|
2018-07-04 16:31:00 +02:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
Retention: Final = "m.room.retention"
|
2019-11-04 18:09:22 +01:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
Dummy: Final = "org.matrix.dummy_event"
|
2020-12-18 10:49:18 +01:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
SpaceChild: Final = "m.space.child"
|
|
|
|
SpaceParent: Final = "m.space.parent"
|
2021-03-18 19:24:16 +01:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
MSC2716_INSERTION: Final = "org.matrix.msc2716.insertion"
|
|
|
|
MSC2716_BATCH: Final = "org.matrix.msc2716.batch"
|
|
|
|
MSC2716_MARKER: Final = "org.matrix.msc2716.marker"
|
2021-06-22 11:02:53 +02:00
|
|
|
|
2022-11-03 17:21:31 +01:00
|
|
|
Reaction: Final = "m.reaction"
|
|
|
|
|
2015-01-28 17:16:53 +01:00
|
|
|
|
2021-05-11 12:02:56 +02:00
|
|
|
class ToDeviceEventTypes:
|
2021-11-25 17:14:23 +01:00
|
|
|
RoomKeyRequest: Final = "m.room_key_request"
|
2021-05-11 12:02:56 +02:00
|
|
|
|
|
|
|
|
2021-07-27 15:36:38 +02:00
|
|
|
class DeviceKeyAlgorithms:
|
|
|
|
"""Spec'd algorithms for the generation of per-device keys"""
|
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
ED25519: Final = "ed25519"
|
|
|
|
CURVE25519: Final = "curve25519"
|
|
|
|
SIGNED_CURVE25519: Final = "signed_curve25519"
|
2021-07-27 15:36:38 +02:00
|
|
|
|
|
|
|
|
2021-02-19 19:20:34 +01:00
|
|
|
class EduTypes:
|
2022-05-27 13:14:36 +02:00
|
|
|
PRESENCE: Final = "m.presence"
|
|
|
|
TYPING: Final = "m.typing"
|
|
|
|
RECEIPT: Final = "m.receipt"
|
|
|
|
DEVICE_LIST_UPDATE: Final = "m.device_list_update"
|
|
|
|
SIGNING_KEY_UPDATE: Final = "m.signing_key_update"
|
|
|
|
UNSTABLE_SIGNING_KEY_UPDATE: Final = "org.matrix.signing_key_update"
|
|
|
|
DIRECT_TO_DEVICE: Final = "m.direct_to_device"
|
2021-02-19 19:20:34 +01:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class RejectedReason:
|
2021-11-25 17:14:23 +01:00
|
|
|
AUTH_ERROR: Final = "auth_error"
|
2022-12-13 14:19:19 +01:00
|
|
|
OVERSIZED_EVENT: Final = "oversized_event"
|
2015-07-13 17:48:06 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class RoomCreationPreset:
|
2021-11-25 17:14:23 +01:00
|
|
|
PRIVATE_CHAT: Final = "private_chat"
|
|
|
|
PUBLIC_CHAT: Final = "public_chat"
|
|
|
|
TRUSTED_PRIVATE_CHAT: Final = "trusted_private_chat"
|
2016-08-25 19:34:47 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class ThirdPartyEntityKind:
|
2021-11-25 17:14:23 +01:00
|
|
|
USER: Final = "user"
|
|
|
|
LOCATION: Final = "location"
|
2018-07-25 23:10:39 +02:00
|
|
|
|
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
ServerNoticeMsgType: Final = "m.server_notice"
|
|
|
|
ServerNoticeLimitReached: Final = "m.server_notice.usage_limit_reached"
|
2018-12-14 19:20:59 +01:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class UserTypes:
|
2018-12-14 19:20:59 +01:00
|
|
|
"""Allows for user type specific behaviour. With the benefit of hindsight
|
|
|
|
'admin' and 'guest' users should also be UserTypes. Normal users are type None
|
|
|
|
"""
|
2019-06-20 11:32:02 +02:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
SUPPORT: Final = "support"
|
|
|
|
BOT: Final = "bot"
|
|
|
|
ALL_USER_TYPES: Final = (SUPPORT, BOT)
|
2019-05-14 17:59:21 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class RelationTypes:
|
2021-02-16 23:32:34 +01:00
|
|
|
"""The types of relations known to this server."""
|
2019-06-20 11:32:02 +02:00
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
ANNOTATION: Final = "m.annotation"
|
|
|
|
REPLACE: Final = "m.replace"
|
|
|
|
REFERENCE: Final = "m.reference"
|
2022-03-10 16:36:13 +01:00
|
|
|
THREAD: Final = "m.thread"
|
2019-10-24 12:48:46 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class LimitBlockingTypes:
|
2019-10-24 12:48:46 +02:00
|
|
|
"""Reasons that a server may be blocked"""
|
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
MONTHLY_ACTIVE_USER: Final = "monthly_active_user"
|
|
|
|
HS_DISABLED: Final = "hs_disabled"
|
2019-10-29 19:35:49 +01:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class EventContentFields:
|
2019-11-01 11:30:51 +01:00
|
|
|
"""Fields found in events' content, regardless of type."""
|
2019-11-01 11:39:14 +01:00
|
|
|
|
2019-11-01 11:30:51 +01:00
|
|
|
# Labels for the event, cf https://github.com/matrix-org/matrix-doc/pull/2326
|
2021-11-25 17:14:23 +01:00
|
|
|
LABELS: Final = "org.matrix.labels"
|
2019-12-03 20:19:45 +01:00
|
|
|
|
|
|
|
# Timestamp to delete the event after
|
|
|
|
# cf https://github.com/matrix-org/matrix-doc/pull/2228
|
2021-11-25 17:14:23 +01:00
|
|
|
SELF_DESTRUCT_AFTER: Final = "org.matrix.self_destruct_after"
|
2020-06-10 18:44:34 +02:00
|
|
|
|
2021-03-18 19:24:16 +01:00
|
|
|
# cf https://github.com/matrix-org/matrix-doc/pull/1772
|
2021-11-25 17:14:23 +01:00
|
|
|
ROOM_TYPE: Final = "type"
|
2021-03-18 19:24:16 +01:00
|
|
|
|
2021-09-08 16:00:43 +02:00
|
|
|
# Whether a room can federate.
|
2021-11-25 17:14:23 +01:00
|
|
|
FEDERATE: Final = "m.federate"
|
2021-09-08 16:00:43 +02:00
|
|
|
|
2021-09-01 17:27:58 +02:00
|
|
|
# The creator of the room, as used in `m.room.create` events.
|
2023-04-06 22:26:28 +02:00
|
|
|
#
|
|
|
|
# This is deprecated in MSC2175.
|
2021-11-25 17:14:23 +01:00
|
|
|
ROOM_CREATOR: Final = "creator"
|
2021-09-01 17:27:58 +02:00
|
|
|
|
2021-09-06 13:17:16 +02:00
|
|
|
# Used in m.room.guest_access events.
|
2021-11-25 17:14:23 +01:00
|
|
|
GUEST_ACCESS: Final = "guest_access"
|
2021-09-06 13:17:16 +02:00
|
|
|
|
2021-06-22 11:02:53 +02:00
|
|
|
# Used on normal messages to indicate they were historically imported after the fact
|
2021-11-25 17:14:23 +01:00
|
|
|
MSC2716_HISTORICAL: Final = "org.matrix.msc2716.historical"
|
2021-09-21 22:06:28 +02:00
|
|
|
# For "insertion" events to indicate what the next batch ID should be in
|
2021-07-21 12:29:57 +02:00
|
|
|
# order to connect to it
|
2022-08-19 22:37:01 +02:00
|
|
|
MSC2716_NEXT_BATCH_ID: Final = "next_batch_id"
|
2021-09-21 22:06:28 +02:00
|
|
|
# Used on "batch" events to indicate which insertion event it connects to
|
2022-08-19 22:37:01 +02:00
|
|
|
MSC2716_BATCH_ID: Final = "batch_id"
|
2021-06-22 11:02:53 +02:00
|
|
|
# For "marker" events
|
2022-08-19 22:37:01 +02:00
|
|
|
MSC2716_INSERTION_EVENT_REFERENCE: Final = "insertion_event_reference"
|
2021-06-22 11:02:53 +02:00
|
|
|
|
2021-09-30 17:13:59 +02:00
|
|
|
# The authorising user for joining a restricted room.
|
2021-11-25 17:14:23 +01:00
|
|
|
AUTHORISING_USER: Final = "join_authorised_via_users_server"
|
2021-09-30 17:13:59 +02:00
|
|
|
|
2023-01-27 16:16:21 +01:00
|
|
|
# Use for mentioning users.
|
2023-06-06 10:11:07 +02:00
|
|
|
MENTIONS: Final = "m.mentions"
|
2023-01-27 16:16:21 +01:00
|
|
|
|
2022-12-06 10:52:55 +01:00
|
|
|
# an unspecced field added to to-device messages to identify them uniquely-ish
|
|
|
|
TO_DEVICE_MSGID: Final = "org.matrix.msgid"
|
|
|
|
|
2020-06-10 18:44:34 +02:00
|
|
|
|
2021-06-29 18:00:04 +02:00
|
|
|
class RoomTypes:
|
|
|
|
"""Understood values of the room_type field of m.room.create events."""
|
|
|
|
|
2021-11-25 17:14:23 +01:00
|
|
|
SPACE: Final = "m.space"
|
2021-06-29 18:00:04 +02:00
|
|
|
|
|
|
|
|
2020-09-04 12:54:56 +02:00
|
|
|
class RoomEncryptionAlgorithms:
|
2021-11-25 17:14:23 +01:00
|
|
|
MEGOLM_V1_AES_SHA2: Final = "m.megolm.v1.aes-sha2"
|
|
|
|
DEFAULT: Final = MEGOLM_V1_AES_SHA2
|
2020-10-05 15:28:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
class AccountDataTypes:
|
2021-11-25 17:14:23 +01:00
|
|
|
DIRECT: Final = "m.direct"
|
|
|
|
IGNORED_USER_LIST: Final = "m.ignored_user_list"
|
2023-01-13 15:57:43 +01:00
|
|
|
TAG: Final = "m.tag"
|
2023-05-09 13:23:27 +02:00
|
|
|
PUSH_RULES: Final = "m.push_rules"
|
2020-12-16 14:46:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
class HistoryVisibility:
|
2021-11-25 17:14:23 +01:00
|
|
|
INVITED: Final = "invited"
|
|
|
|
JOINED: Final = "joined"
|
|
|
|
SHARED: Final = "shared"
|
|
|
|
WORLD_READABLE: Final = "world_readable"
|
2021-07-28 10:05:11 +02:00
|
|
|
|
|
|
|
|
2021-09-06 13:17:16 +02:00
|
|
|
class GuestAccess:
|
2021-11-25 17:14:23 +01:00
|
|
|
CAN_JOIN: Final = "can_join"
|
2021-09-06 13:17:16 +02:00
|
|
|
# anything that is not "can_join" is considered "forbidden", but for completeness:
|
2021-11-25 17:14:23 +01:00
|
|
|
FORBIDDEN: Final = "forbidden"
|
2021-09-06 13:17:16 +02:00
|
|
|
|
|
|
|
|
2021-12-08 18:26:29 +01:00
|
|
|
class ReceiptTypes:
|
|
|
|
READ: Final = "m.read"
|
2022-08-05 17:09:33 +02:00
|
|
|
READ_PRIVATE: Final = "m.read.private"
|
2022-05-04 17:59:22 +02:00
|
|
|
FULLY_READ: Final = "m.fully_read"
|
2022-06-29 19:12:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PublicRoomsFilterFields:
|
|
|
|
"""Fields in the search filter for `/publicRooms` that we understand.
|
|
|
|
|
|
|
|
As defined in https://spec.matrix.org/v1.3/client-server-api/#post_matrixclientv3publicrooms
|
|
|
|
"""
|
|
|
|
|
|
|
|
GENERIC_SEARCH_TERM: Final = "generic_search_term"
|
2022-07-27 20:46:57 +02:00
|
|
|
ROOM_TYPES: Final = "room_types"
|
2022-09-29 15:23:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ApprovalNoticeMedium:
|
|
|
|
"""Identifier for the medium this server will use to serve notice of approval for a
|
|
|
|
specific user's registration.
|
|
|
|
|
|
|
|
As defined in https://github.com/matrix-org/matrix-spec-proposals/blob/babolivier/m_not_approved/proposals/3866-user-not-approved-error.md
|
|
|
|
"""
|
|
|
|
|
|
|
|
NONE = "org.matrix.msc3866.none"
|
|
|
|
EMAIL = "org.matrix.msc3866.email"
|
2023-01-27 13:27:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Direction(enum.Enum):
|
|
|
|
BACKWARDS = "b"
|
|
|
|
FORWARDS = "f"
|