constants.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2014-2016 OpenMarket Ltd
  3. # Copyright 2017 Vector Creations Ltd
  4. # Copyright 2018-2019 New Vector Ltd
  5. # Copyright 2019 The Matrix.org Foundation C.I.C.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. """Contains constants from the specification."""
  19. # the "depth" field on events is limited to 2**63 - 1
  20. MAX_DEPTH = 2 ** 63 - 1
  21. # the maximum length for a room alias is 255 characters
  22. MAX_ALIAS_LENGTH = 255
  23. # the maximum length for a user id is 255 characters
  24. MAX_USERID_LENGTH = 255
  25. class Membership(object):
  26. """Represents the membership states of a user in a room."""
  27. INVITE = "invite"
  28. JOIN = "join"
  29. KNOCK = "knock"
  30. LEAVE = "leave"
  31. BAN = "ban"
  32. LIST = (INVITE, JOIN, KNOCK, LEAVE, BAN)
  33. class PresenceState(object):
  34. """Represents the presence state of a user."""
  35. OFFLINE = "offline"
  36. UNAVAILABLE = "unavailable"
  37. ONLINE = "online"
  38. class JoinRules(object):
  39. PUBLIC = "public"
  40. KNOCK = "knock"
  41. INVITE = "invite"
  42. PRIVATE = "private"
  43. class LoginType(object):
  44. PASSWORD = "m.login.password"
  45. EMAIL_IDENTITY = "m.login.email.identity"
  46. MSISDN = "m.login.msisdn"
  47. RECAPTCHA = "m.login.recaptcha"
  48. TERMS = "m.login.terms"
  49. SSO = "m.login.sso"
  50. DUMMY = "m.login.dummy"
  51. class EventTypes(object):
  52. Member = "m.room.member"
  53. Create = "m.room.create"
  54. Tombstone = "m.room.tombstone"
  55. JoinRules = "m.room.join_rules"
  56. PowerLevels = "m.room.power_levels"
  57. Aliases = "m.room.aliases"
  58. Redaction = "m.room.redaction"
  59. ThirdPartyInvite = "m.room.third_party_invite"
  60. RelatedGroups = "m.room.related_groups"
  61. RoomHistoryVisibility = "m.room.history_visibility"
  62. CanonicalAlias = "m.room.canonical_alias"
  63. Encrypted = "m.room.encrypted"
  64. RoomAvatar = "m.room.avatar"
  65. RoomEncryption = "m.room.encryption"
  66. GuestAccess = "m.room.guest_access"
  67. # These are used for validation
  68. Message = "m.room.message"
  69. Topic = "m.room.topic"
  70. Name = "m.room.name"
  71. ServerACL = "m.room.server_acl"
  72. Pinned = "m.room.pinned_events"
  73. Retention = "m.room.retention"
  74. Presence = "m.presence"
  75. class RejectedReason(object):
  76. AUTH_ERROR = "auth_error"
  77. class RoomCreationPreset(object):
  78. PRIVATE_CHAT = "private_chat"
  79. PUBLIC_CHAT = "public_chat"
  80. TRUSTED_PRIVATE_CHAT = "trusted_private_chat"
  81. class ThirdPartyEntityKind(object):
  82. USER = "user"
  83. LOCATION = "location"
  84. ServerNoticeMsgType = "m.server_notice"
  85. ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
  86. class UserTypes(object):
  87. """Allows for user type specific behaviour. With the benefit of hindsight
  88. 'admin' and 'guest' users should also be UserTypes. Normal users are type None
  89. """
  90. SUPPORT = "support"
  91. BOT = "bot"
  92. ALL_USER_TYPES = (SUPPORT, BOT)
  93. class RelationTypes(object):
  94. """The types of relations known to this server.
  95. """
  96. ANNOTATION = "m.annotation"
  97. REPLACE = "m.replace"
  98. REFERENCE = "m.reference"
  99. class LimitBlockingTypes(object):
  100. """Reasons that a server may be blocked"""
  101. MONTHLY_ACTIVE_USER = "monthly_active_user"
  102. HS_DISABLED = "hs_disabled"
  103. class EventContentFields(object):
  104. """Fields found in events' content, regardless of type."""
  105. # Labels for the event, cf https://github.com/matrix-org/matrix-doc/pull/2326
  106. LABELS = "org.matrix.labels"
  107. # Timestamp to delete the event after
  108. # cf https://github.com/matrix-org/matrix-doc/pull/2228
  109. SELF_DESTRUCT_AFTER = "org.matrix.self_destruct_after"