constants.py 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. # Copyright 2014-2016 OpenMarket Ltd
  2. # Copyright 2017 Vector Creations Ltd
  3. # Copyright 2018-2019 New Vector Ltd
  4. # Copyright 2019 The Matrix.org Foundation C.I.C.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. """Contains constants from the specification."""
  18. # the max size of a (canonical-json-encoded) event
  19. MAX_PDU_SIZE = 65536
  20. # the "depth" field on events is limited to 2**63 - 1
  21. MAX_DEPTH = 2 ** 63 - 1
  22. # the maximum length for a room alias is 255 characters
  23. MAX_ALIAS_LENGTH = 255
  24. # the maximum length for a user id is 255 characters
  25. MAX_USERID_LENGTH = 255
  26. # The maximum length for a group id is 255 characters
  27. MAX_GROUPID_LENGTH = 255
  28. MAX_GROUP_CATEGORYID_LENGTH = 255
  29. MAX_GROUP_ROLEID_LENGTH = 255
  30. class Membership:
  31. """Represents the membership states of a user in a room."""
  32. INVITE = "invite"
  33. JOIN = "join"
  34. KNOCK = "knock"
  35. LEAVE = "leave"
  36. BAN = "ban"
  37. LIST = (INVITE, JOIN, KNOCK, LEAVE, BAN)
  38. class PresenceState:
  39. """Represents the presence state of a user."""
  40. OFFLINE = "offline"
  41. UNAVAILABLE = "unavailable"
  42. ONLINE = "online"
  43. BUSY = "org.matrix.msc3026.busy"
  44. class JoinRules:
  45. PUBLIC = "public"
  46. KNOCK = "knock"
  47. INVITE = "invite"
  48. PRIVATE = "private"
  49. # As defined for MSC3083.
  50. RESTRICTED = "restricted"
  51. class RestrictedJoinRuleTypes:
  52. """Understood types for the allow rules in restricted join rules."""
  53. ROOM_MEMBERSHIP = "m.room_membership"
  54. class LoginType:
  55. PASSWORD = "m.login.password"
  56. EMAIL_IDENTITY = "m.login.email.identity"
  57. MSISDN = "m.login.msisdn"
  58. RECAPTCHA = "m.login.recaptcha"
  59. TERMS = "m.login.terms"
  60. SSO = "m.login.sso"
  61. DUMMY = "m.login.dummy"
  62. # This is used in the `type` parameter for /register when called by
  63. # an appservice to register a new user.
  64. APP_SERVICE_REGISTRATION_TYPE = "m.login.application_service"
  65. class EventTypes:
  66. Member = "m.room.member"
  67. Create = "m.room.create"
  68. Tombstone = "m.room.tombstone"
  69. JoinRules = "m.room.join_rules"
  70. PowerLevels = "m.room.power_levels"
  71. Aliases = "m.room.aliases"
  72. Redaction = "m.room.redaction"
  73. ThirdPartyInvite = "m.room.third_party_invite"
  74. RelatedGroups = "m.room.related_groups"
  75. RoomHistoryVisibility = "m.room.history_visibility"
  76. CanonicalAlias = "m.room.canonical_alias"
  77. Encrypted = "m.room.encrypted"
  78. RoomAvatar = "m.room.avatar"
  79. RoomEncryption = "m.room.encryption"
  80. GuestAccess = "m.room.guest_access"
  81. # These are used for validation
  82. Message = "m.room.message"
  83. Topic = "m.room.topic"
  84. Name = "m.room.name"
  85. ServerACL = "m.room.server_acl"
  86. Pinned = "m.room.pinned_events"
  87. Retention = "m.room.retention"
  88. Dummy = "org.matrix.dummy_event"
  89. SpaceChild = "m.space.child"
  90. SpaceParent = "m.space.parent"
  91. MSC2716_INSERTION = "org.matrix.msc2716.insertion"
  92. MSC2716_CHUNK = "org.matrix.msc2716.chunk"
  93. MSC2716_MARKER = "org.matrix.msc2716.marker"
  94. class ToDeviceEventTypes:
  95. RoomKeyRequest = "m.room_key_request"
  96. class DeviceKeyAlgorithms:
  97. """Spec'd algorithms for the generation of per-device keys"""
  98. ED25519 = "ed25519"
  99. CURVE25519 = "curve25519"
  100. SIGNED_CURVE25519 = "signed_curve25519"
  101. class EduTypes:
  102. Presence = "m.presence"
  103. class RejectedReason:
  104. AUTH_ERROR = "auth_error"
  105. class RoomCreationPreset:
  106. PRIVATE_CHAT = "private_chat"
  107. PUBLIC_CHAT = "public_chat"
  108. TRUSTED_PRIVATE_CHAT = "trusted_private_chat"
  109. class ThirdPartyEntityKind:
  110. USER = "user"
  111. LOCATION = "location"
  112. ServerNoticeMsgType = "m.server_notice"
  113. ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
  114. class UserTypes:
  115. """Allows for user type specific behaviour. With the benefit of hindsight
  116. 'admin' and 'guest' users should also be UserTypes. Normal users are type None
  117. """
  118. SUPPORT = "support"
  119. BOT = "bot"
  120. ALL_USER_TYPES = (SUPPORT, BOT)
  121. class RelationTypes:
  122. """The types of relations known to this server."""
  123. ANNOTATION = "m.annotation"
  124. REPLACE = "m.replace"
  125. REFERENCE = "m.reference"
  126. class LimitBlockingTypes:
  127. """Reasons that a server may be blocked"""
  128. MONTHLY_ACTIVE_USER = "monthly_active_user"
  129. HS_DISABLED = "hs_disabled"
  130. class EventContentFields:
  131. """Fields found in events' content, regardless of type."""
  132. # Labels for the event, cf https://github.com/matrix-org/matrix-doc/pull/2326
  133. LABELS = "org.matrix.labels"
  134. # Timestamp to delete the event after
  135. # cf https://github.com/matrix-org/matrix-doc/pull/2228
  136. SELF_DESTRUCT_AFTER = "org.matrix.self_destruct_after"
  137. # cf https://github.com/matrix-org/matrix-doc/pull/1772
  138. ROOM_TYPE = "type"
  139. # Used on normal messages to indicate they were historically imported after the fact
  140. MSC2716_HISTORICAL = "org.matrix.msc2716.historical"
  141. # For "insertion" events to indicate what the next chunk ID should be in
  142. # order to connect to it
  143. MSC2716_NEXT_CHUNK_ID = "org.matrix.msc2716.next_chunk_id"
  144. # Used on "chunk" events to indicate which insertion event it connects to
  145. MSC2716_CHUNK_ID = "org.matrix.msc2716.chunk_id"
  146. # For "marker" events
  147. MSC2716_MARKER_INSERTION = "org.matrix.msc2716.marker.insertion"
  148. class RoomTypes:
  149. """Understood values of the room_type field of m.room.create events."""
  150. SPACE = "m.space"
  151. class RoomEncryptionAlgorithms:
  152. MEGOLM_V1_AES_SHA2 = "m.megolm.v1.aes-sha2"
  153. DEFAULT = MEGOLM_V1_AES_SHA2
  154. class AccountDataTypes:
  155. DIRECT = "m.direct"
  156. IGNORED_USER_LIST = "m.ignored_user_list"
  157. class HistoryVisibility:
  158. INVITED = "invited"
  159. JOINED = "joined"
  160. SHARED = "shared"
  161. WORLD_READABLE = "world_readable"
  162. class ReadReceiptEventFields:
  163. MSC2285_HIDDEN = "org.matrix.msc2285.hidden"