You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

192 lines
4.9 KiB

  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 "depth" field on events is limited to 2**63 - 1
  19. MAX_DEPTH = 2 ** 63 - 1
  20. # the maximum length for a room alias is 255 characters
  21. MAX_ALIAS_LENGTH = 255
  22. # the maximum length for a user id is 255 characters
  23. MAX_USERID_LENGTH = 255
  24. # The maximum length for a group id is 255 characters
  25. MAX_GROUPID_LENGTH = 255
  26. MAX_GROUP_CATEGORYID_LENGTH = 255
  27. MAX_GROUP_ROLEID_LENGTH = 255
  28. class Membership:
  29. """Represents the membership states of a user in a room."""
  30. INVITE = "invite"
  31. JOIN = "join"
  32. KNOCK = "knock"
  33. LEAVE = "leave"
  34. BAN = "ban"
  35. LIST = (INVITE, JOIN, KNOCK, LEAVE, BAN)
  36. class PresenceState:
  37. """Represents the presence state of a user."""
  38. OFFLINE = "offline"
  39. UNAVAILABLE = "unavailable"
  40. ONLINE = "online"
  41. BUSY = "org.matrix.msc3026.busy"
  42. class JoinRules:
  43. PUBLIC = "public"
  44. KNOCK = "knock"
  45. INVITE = "invite"
  46. PRIVATE = "private"
  47. # As defined for MSC3083.
  48. MSC3083_RESTRICTED = "restricted"
  49. class LoginType:
  50. PASSWORD = "m.login.password"
  51. EMAIL_IDENTITY = "m.login.email.identity"
  52. MSISDN = "m.login.msisdn"
  53. RECAPTCHA = "m.login.recaptcha"
  54. TERMS = "m.login.terms"
  55. SSO = "m.login.sso"
  56. DUMMY = "m.login.dummy"
  57. # This is used in the `type` parameter for /register when called by
  58. # an appservice to register a new user.
  59. APP_SERVICE_REGISTRATION_TYPE = "m.login.application_service"
  60. class EventTypes:
  61. Member = "m.room.member"
  62. Create = "m.room.create"
  63. Tombstone = "m.room.tombstone"
  64. JoinRules = "m.room.join_rules"
  65. PowerLevels = "m.room.power_levels"
  66. Aliases = "m.room.aliases"
  67. Redaction = "m.room.redaction"
  68. ThirdPartyInvite = "m.room.third_party_invite"
  69. RelatedGroups = "m.room.related_groups"
  70. RoomHistoryVisibility = "m.room.history_visibility"
  71. CanonicalAlias = "m.room.canonical_alias"
  72. Encrypted = "m.room.encrypted"
  73. RoomAvatar = "m.room.avatar"
  74. RoomEncryption = "m.room.encryption"
  75. GuestAccess = "m.room.guest_access"
  76. # These are used for validation
  77. Message = "m.room.message"
  78. Topic = "m.room.topic"
  79. Name = "m.room.name"
  80. ServerACL = "m.room.server_acl"
  81. Pinned = "m.room.pinned_events"
  82. Retention = "m.room.retention"
  83. Dummy = "org.matrix.dummy_event"
  84. MSC1772_SPACE_CHILD = "org.matrix.msc1772.space.child"
  85. MSC1772_SPACE_PARENT = "org.matrix.msc1772.space.parent"
  86. class EduTypes:
  87. Presence = "m.presence"
  88. RoomKeyRequest = "m.room_key_request"
  89. class RejectedReason:
  90. AUTH_ERROR = "auth_error"
  91. class RoomCreationPreset:
  92. PRIVATE_CHAT = "private_chat"
  93. PUBLIC_CHAT = "public_chat"
  94. TRUSTED_PRIVATE_CHAT = "trusted_private_chat"
  95. class ThirdPartyEntityKind:
  96. USER = "user"
  97. LOCATION = "location"
  98. ServerNoticeMsgType = "m.server_notice"
  99. ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
  100. class UserTypes:
  101. """Allows for user type specific behaviour. With the benefit of hindsight
  102. 'admin' and 'guest' users should also be UserTypes. Normal users are type None
  103. """
  104. SUPPORT = "support"
  105. BOT = "bot"
  106. ALL_USER_TYPES = (SUPPORT, BOT)
  107. class RelationTypes:
  108. """The types of relations known to this server."""
  109. ANNOTATION = "m.annotation"
  110. REPLACE = "m.replace"
  111. REFERENCE = "m.reference"
  112. class LimitBlockingTypes:
  113. """Reasons that a server may be blocked"""
  114. MONTHLY_ACTIVE_USER = "monthly_active_user"
  115. HS_DISABLED = "hs_disabled"
  116. class EventContentFields:
  117. """Fields found in events' content, regardless of type."""
  118. # Labels for the event, cf https://github.com/matrix-org/matrix-doc/pull/2326
  119. LABELS = "org.matrix.labels"
  120. # Timestamp to delete the event after
  121. # cf https://github.com/matrix-org/matrix-doc/pull/2228
  122. SELF_DESTRUCT_AFTER = "org.matrix.self_destruct_after"
  123. # cf https://github.com/matrix-org/matrix-doc/pull/1772
  124. MSC1772_ROOM_TYPE = "org.matrix.msc1772.type"
  125. class RoomEncryptionAlgorithms:
  126. MEGOLM_V1_AES_SHA2 = "m.megolm.v1.aes-sha2"
  127. DEFAULT = MEGOLM_V1_AES_SHA2
  128. class AccountDataTypes:
  129. DIRECT = "m.direct"
  130. IGNORED_USER_LIST = "m.ignored_user_list"
  131. class HistoryVisibility:
  132. INVITED = "invited"
  133. JOINED = "joined"
  134. SHARED = "shared"
  135. WORLD_READABLE = "world_readable"