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