2016-01-06 21:26:29 -07:00
|
|
|
# Copyright 2014-2016 OpenMarket Ltd
|
2017-03-13 11:27:51 -06:00
|
|
|
# Copyright 2017 Vector Creations Ltd
|
2019-11-05 03:56:39 -07:00
|
|
|
# Copyright 2018-2019 New Vector Ltd
|
|
|
|
# Copyright 2019 The Matrix.org Foundation C.I.C.
|
2014-08-12 08:10:52 -06: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-12 20:14:34 -06:00
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
"""Contains constants from the specification."""
|
|
|
|
|
2023-01-27 05:27:55 -07:00
|
|
|
import enum
|
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
from typing_extensions import Final
|
|
|
|
|
2021-04-23 12:20:44 -06:00
|
|
|
# the max size of a (canonical-json-encoded) event
|
|
|
|
MAX_PDU_SIZE = 65536
|
|
|
|
|
2018-05-01 09:19:39 -06:00
|
|
|
# the "depth" field on events is limited to 2**63 - 1
|
2022-03-29 04:41:19 -06:00
|
|
|
MAX_DEPTH = 2**63 - 1
|
2018-05-01 09:19:39 -06:00
|
|
|
|
2019-05-08 10:01:30 -06:00
|
|
|
# the maximum length for a room alias is 255 characters
|
|
|
|
MAX_ALIAS_LENGTH = 255
|
|
|
|
|
2019-05-20 04:20:08 -06:00
|
|
|
# the maximum length for a user id is 255 characters
|
|
|
|
MAX_USERID_LENGTH = 255
|
|
|
|
|
2022-10-04 07:47:04 -06:00
|
|
|
# Constant value used for the pseudo-thread which is the main timeline.
|
|
|
|
MAIN_TIMELINE: Final = "main"
|
|
|
|
|
2014-08-12 08:10:52 -06:00
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class Membership:
|
2014-08-12 08:10:52 -06:00
|
|
|
|
|
|
|
"""Represents the membership states of a user in a room."""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2021-11-25 09:14:23 -07: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 08:10:52 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class PresenceState:
|
2014-08-12 08:10:52 -06:00
|
|
|
"""Represents the presence state of a user."""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
OFFLINE: Final = "offline"
|
|
|
|
UNAVAILABLE: Final = "unavailable"
|
|
|
|
ONLINE: Final = "online"
|
|
|
|
BUSY: Final = "org.matrix.msc3026.busy"
|
2014-08-28 03:59:15 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class JoinRules:
|
2021-11-25 09:14:23 -07:00
|
|
|
PUBLIC: Final = "public"
|
|
|
|
KNOCK: Final = "knock"
|
|
|
|
INVITE: Final = "invite"
|
|
|
|
PRIVATE: Final = "private"
|
2021-03-31 14:39:08 -06:00
|
|
|
# As defined for MSC3083.
|
2021-11-25 09:14:23 -07:00
|
|
|
RESTRICTED: Final = "restricted"
|
2022-05-17 04:41:39 -06:00
|
|
|
# As defined for MSC3787.
|
|
|
|
KNOCK_RESTRICTED: Final = "knock_restricted"
|
2014-09-15 03:23:20 -06:00
|
|
|
|
|
|
|
|
2021-06-17 10:53:27 -06:00
|
|
|
class RestrictedJoinRuleTypes:
|
|
|
|
"""Understood types for the allow rules in restricted join rules."""
|
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
ROOM_MEMBERSHIP: Final = "m.room_membership"
|
2021-06-17 10:53:27 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class LoginType:
|
2021-11-25 09:14:23 -07: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 05:15:13 -07:00
|
|
|
REGISTRATION_TOKEN: Final = "m.login.registration_token"
|
2015-04-02 10:01:29 -06:00
|
|
|
|
2014-12-03 09:07:21 -07:00
|
|
|
|
2021-04-12 08:13:55 -06:00
|
|
|
# This is used in the `type` parameter for /register when called by
|
|
|
|
# an appservice to register a new user.
|
2021-11-25 09:14:23 -07:00
|
|
|
APP_SERVICE_REGISTRATION_TYPE: Final = "m.login.application_service"
|
2021-04-12 08:13:55 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class EventTypes:
|
2021-11-25 09:14:23 -07: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 09:20:10 -06:00
|
|
|
|
2014-12-12 03:56:14 -07:00
|
|
|
# These are used for validation
|
2021-11-25 09:14:23 -07:00
|
|
|
Message: Final = "m.room.message"
|
|
|
|
Topic: Final = "m.room.topic"
|
|
|
|
Name: Final = "m.room.name"
|
2015-01-28 09:16:53 -07:00
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
ServerACL: Final = "m.room.server_acl"
|
|
|
|
Pinned: Final = "m.room.pinned_events"
|
2018-07-04 08:31:00 -06:00
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
Retention: Final = "m.room.retention"
|
2019-11-04 10:09:22 -07:00
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
Dummy: Final = "org.matrix.dummy_event"
|
2020-12-18 02:49:18 -07:00
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
SpaceChild: Final = "m.space.child"
|
|
|
|
SpaceParent: Final = "m.space.parent"
|
2021-03-18 12:24:16 -06:00
|
|
|
|
2021-11-25 09:14:23 -07: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 03:02:53 -06:00
|
|
|
|
2022-11-03 10:21:31 -06:00
|
|
|
Reaction: Final = "m.reaction"
|
|
|
|
|
2015-01-28 09:16:53 -07:00
|
|
|
|
2021-05-11 04:02:56 -06:00
|
|
|
class ToDeviceEventTypes:
|
2021-11-25 09:14:23 -07:00
|
|
|
RoomKeyRequest: Final = "m.room_key_request"
|
2021-05-11 04:02:56 -06:00
|
|
|
|
|
|
|
|
2021-07-27 07:36:38 -06:00
|
|
|
class DeviceKeyAlgorithms:
|
|
|
|
"""Spec'd algorithms for the generation of per-device keys"""
|
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
ED25519: Final = "ed25519"
|
|
|
|
CURVE25519: Final = "curve25519"
|
|
|
|
SIGNED_CURVE25519: Final = "signed_curve25519"
|
2021-07-27 07:36:38 -06:00
|
|
|
|
|
|
|
|
2021-02-19 11:20:34 -07:00
|
|
|
class EduTypes:
|
2022-05-27 05:14:36 -06: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 11:20:34 -07:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class RejectedReason:
|
2021-11-25 09:14:23 -07:00
|
|
|
AUTH_ERROR: Final = "auth_error"
|
2022-12-13 06:19:19 -07:00
|
|
|
OVERSIZED_EVENT: Final = "oversized_event"
|
2015-07-13 09:48:06 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class RoomCreationPreset:
|
2021-11-25 09:14:23 -07:00
|
|
|
PRIVATE_CHAT: Final = "private_chat"
|
|
|
|
PUBLIC_CHAT: Final = "public_chat"
|
|
|
|
TRUSTED_PRIVATE_CHAT: Final = "trusted_private_chat"
|
2016-08-25 11:34:47 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class ThirdPartyEntityKind:
|
2021-11-25 09:14:23 -07:00
|
|
|
USER: Final = "user"
|
|
|
|
LOCATION: Final = "location"
|
2018-07-25 15:10:39 -06:00
|
|
|
|
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
ServerNoticeMsgType: Final = "m.server_notice"
|
|
|
|
ServerNoticeLimitReached: Final = "m.server_notice.usage_limit_reached"
|
2018-12-14 11:20:59 -07:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class UserTypes:
|
2018-12-14 11:20:59 -07: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 03:32:02 -06:00
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
SUPPORT: Final = "support"
|
|
|
|
BOT: Final = "bot"
|
|
|
|
ALL_USER_TYPES: Final = (SUPPORT, BOT)
|
2019-05-14 09:59:21 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class RelationTypes:
|
2019-05-14 09:59:21 -06:00
|
|
|
"""The types of relations known to this server."""
|
2019-06-20 03:32:02 -06:00
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
ANNOTATION: Final = "m.annotation"
|
|
|
|
REPLACE: Final = "m.replace"
|
|
|
|
REFERENCE: Final = "m.reference"
|
2022-03-10 08:36:13 -07:00
|
|
|
THREAD: Final = "m.thread"
|
2019-10-24 04:48:46 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class LimitBlockingTypes:
|
2019-10-24 04:48:46 -06:00
|
|
|
"""Reasons that a server may be blocked"""
|
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
MONTHLY_ACTIVE_USER: Final = "monthly_active_user"
|
|
|
|
HS_DISABLED: Final = "hs_disabled"
|
2019-10-29 12:35:49 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class EventContentFields:
|
2019-11-01 04:30:51 -06:00
|
|
|
"""Fields found in events' content, regardless of type."""
|
2019-11-01 04:39:14 -06:00
|
|
|
|
2019-11-01 04:30:51 -06:00
|
|
|
# Labels for the event, cf https://github.com/matrix-org/matrix-doc/pull/2326
|
2021-11-25 09:14:23 -07:00
|
|
|
LABELS: Final = "org.matrix.labels"
|
2019-12-03 12:19:45 -07:00
|
|
|
|
|
|
|
# Timestamp to delete the event after
|
|
|
|
# cf https://github.com/matrix-org/matrix-doc/pull/2228
|
2021-11-25 09:14:23 -07:00
|
|
|
SELF_DESTRUCT_AFTER: Final = "org.matrix.self_destruct_after"
|
2020-06-10 10:44:34 -06:00
|
|
|
|
2021-03-18 12:24:16 -06:00
|
|
|
# cf https://github.com/matrix-org/matrix-doc/pull/1772
|
2021-11-25 09:14:23 -07:00
|
|
|
ROOM_TYPE: Final = "type"
|
2021-03-18 12:24:16 -06:00
|
|
|
|
2021-09-08 08:00:43 -06:00
|
|
|
# Whether a room can federate.
|
2021-11-25 09:14:23 -07:00
|
|
|
FEDERATE: Final = "m.federate"
|
2021-09-08 08:00:43 -06:00
|
|
|
|
2021-09-01 09:27:58 -06:00
|
|
|
# The creator of the room, as used in `m.room.create` events.
|
2021-11-25 09:14:23 -07:00
|
|
|
ROOM_CREATOR: Final = "creator"
|
2021-09-01 09:27:58 -06:00
|
|
|
|
2021-09-06 05:17:16 -06:00
|
|
|
# Used in m.room.guest_access events.
|
2021-11-25 09:14:23 -07:00
|
|
|
GUEST_ACCESS: Final = "guest_access"
|
2021-09-06 05:17:16 -06:00
|
|
|
|
2021-06-22 03:02:53 -06:00
|
|
|
# Used on normal messages to indicate they were historically imported after the fact
|
2021-11-25 09:14:23 -07:00
|
|
|
MSC2716_HISTORICAL: Final = "org.matrix.msc2716.historical"
|
2021-09-21 14:06:28 -06:00
|
|
|
# For "insertion" events to indicate what the next batch ID should be in
|
2021-07-21 04:29:57 -06:00
|
|
|
# order to connect to it
|
2022-08-19 14:37:01 -06:00
|
|
|
MSC2716_NEXT_BATCH_ID: Final = "next_batch_id"
|
2021-09-21 14:06:28 -06:00
|
|
|
# Used on "batch" events to indicate which insertion event it connects to
|
2022-08-19 14:37:01 -06:00
|
|
|
MSC2716_BATCH_ID: Final = "batch_id"
|
2021-06-22 03:02:53 -06:00
|
|
|
# For "marker" events
|
2022-08-19 14:37:01 -06:00
|
|
|
MSC2716_INSERTION_EVENT_REFERENCE: Final = "insertion_event_reference"
|
2021-06-22 03:02:53 -06:00
|
|
|
|
2021-09-30 09:13:59 -06:00
|
|
|
# The authorising user for joining a restricted room.
|
2021-11-25 09:14:23 -07:00
|
|
|
AUTHORISING_USER: Final = "join_authorised_via_users_server"
|
2021-09-30 09:13:59 -06:00
|
|
|
|
2023-01-27 08:16:21 -07:00
|
|
|
# Use for mentioning users.
|
|
|
|
MSC3952_MENTIONS: Final = "org.matrix.msc3952.mentions"
|
|
|
|
|
2022-12-06 02:52:55 -07:00
|
|
|
# an unspecced field added to to-device messages to identify them uniquely-ish
|
|
|
|
TO_DEVICE_MSGID: Final = "org.matrix.msgid"
|
|
|
|
|
2020-06-10 10:44:34 -06:00
|
|
|
|
2021-06-29 10:00:04 -06:00
|
|
|
class RoomTypes:
|
|
|
|
"""Understood values of the room_type field of m.room.create events."""
|
|
|
|
|
2021-11-25 09:14:23 -07:00
|
|
|
SPACE: Final = "m.space"
|
2021-06-29 10:00:04 -06:00
|
|
|
|
|
|
|
|
2020-09-04 04:54:56 -06:00
|
|
|
class RoomEncryptionAlgorithms:
|
2021-11-25 09:14:23 -07:00
|
|
|
MEGOLM_V1_AES_SHA2: Final = "m.megolm.v1.aes-sha2"
|
|
|
|
DEFAULT: Final = MEGOLM_V1_AES_SHA2
|
2020-10-05 07:28:05 -06:00
|
|
|
|
|
|
|
|
|
|
|
class AccountDataTypes:
|
2021-11-25 09:14:23 -07:00
|
|
|
DIRECT: Final = "m.direct"
|
|
|
|
IGNORED_USER_LIST: Final = "m.ignored_user_list"
|
2023-01-13 07:57:43 -07:00
|
|
|
TAG: Final = "m.tag"
|
2020-12-16 06:46:37 -07:00
|
|
|
|
|
|
|
|
|
|
|
class HistoryVisibility:
|
2021-11-25 09:14:23 -07:00
|
|
|
INVITED: Final = "invited"
|
|
|
|
JOINED: Final = "joined"
|
|
|
|
SHARED: Final = "shared"
|
|
|
|
WORLD_READABLE: Final = "world_readable"
|
2021-07-28 02:05:11 -06:00
|
|
|
|
|
|
|
|
2021-09-06 05:17:16 -06:00
|
|
|
class GuestAccess:
|
2021-11-25 09:14:23 -07:00
|
|
|
CAN_JOIN: Final = "can_join"
|
2021-09-06 05:17:16 -06:00
|
|
|
# anything that is not "can_join" is considered "forbidden", but for completeness:
|
2021-11-25 09:14:23 -07:00
|
|
|
FORBIDDEN: Final = "forbidden"
|
2021-09-06 05:17:16 -06:00
|
|
|
|
|
|
|
|
2021-12-08 10:26:29 -07:00
|
|
|
class ReceiptTypes:
|
|
|
|
READ: Final = "m.read"
|
2022-08-05 09:09:33 -06:00
|
|
|
READ_PRIVATE: Final = "m.read.private"
|
2022-05-04 09:59:22 -06:00
|
|
|
FULLY_READ: Final = "m.fully_read"
|
2022-06-29 11:12:45 -06: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 12:46:57 -06:00
|
|
|
ROOM_TYPES: Final = "room_types"
|
2022-09-29 07:23:24 -06: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 05:27:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
class Direction(enum.Enum):
|
|
|
|
BACKWARDS = "b"
|
|
|
|
FORWARDS = "f"
|