constants.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2014-2016 OpenMarket Ltd
  3. # Copyright 2017 Vector Creations Ltd
  4. # Copyright 2018 New Vector Ltd.
  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. class Membership(object):
  21. """Represents the membership states of a user in a room."""
  22. INVITE = u"invite"
  23. JOIN = u"join"
  24. KNOCK = u"knock"
  25. LEAVE = u"leave"
  26. BAN = u"ban"
  27. LIST = (INVITE, JOIN, KNOCK, LEAVE, BAN)
  28. class PresenceState(object):
  29. """Represents the presence state of a user."""
  30. OFFLINE = u"offline"
  31. UNAVAILABLE = u"unavailable"
  32. ONLINE = u"online"
  33. class JoinRules(object):
  34. PUBLIC = u"public"
  35. KNOCK = u"knock"
  36. INVITE = u"invite"
  37. PRIVATE = u"private"
  38. class LoginType(object):
  39. PASSWORD = u"m.login.password"
  40. EMAIL_IDENTITY = u"m.login.email.identity"
  41. MSISDN = u"m.login.msisdn"
  42. RECAPTCHA = u"m.login.recaptcha"
  43. TERMS = u"m.login.terms"
  44. DUMMY = u"m.login.dummy"
  45. # Only for C/S API v1
  46. APPLICATION_SERVICE = u"m.login.application_service"
  47. SHARED_SECRET = u"org.matrix.login.shared_secret"
  48. class EventTypes(object):
  49. Member = "m.room.member"
  50. Create = "m.room.create"
  51. Tombstone = "m.room.tombstone"
  52. JoinRules = "m.room.join_rules"
  53. PowerLevels = "m.room.power_levels"
  54. Aliases = "m.room.aliases"
  55. Redaction = "m.room.redaction"
  56. ThirdPartyInvite = "m.room.third_party_invite"
  57. Encryption = "m.room.encryption"
  58. RoomHistoryVisibility = "m.room.history_visibility"
  59. CanonicalAlias = "m.room.canonical_alias"
  60. RoomAvatar = "m.room.avatar"
  61. RoomEncryption = "m.room.encryption"
  62. GuestAccess = "m.room.guest_access"
  63. # These are used for validation
  64. Message = "m.room.message"
  65. Topic = "m.room.topic"
  66. Name = "m.room.name"
  67. ServerACL = "m.room.server_acl"
  68. Pinned = "m.room.pinned_events"
  69. class RejectedReason(object):
  70. AUTH_ERROR = "auth_error"
  71. REPLACED = "replaced"
  72. NOT_ANCESTOR = "not_ancestor"
  73. class RoomCreationPreset(object):
  74. PRIVATE_CHAT = "private_chat"
  75. PUBLIC_CHAT = "public_chat"
  76. TRUSTED_PRIVATE_CHAT = "trusted_private_chat"
  77. class ThirdPartyEntityKind(object):
  78. USER = "user"
  79. LOCATION = "location"
  80. class RoomVersions(object):
  81. V1 = "1"
  82. V2 = "2"
  83. V3 = "3"
  84. STATE_V2_TEST = "state-v2-test"
  85. class RoomDisposition(object):
  86. STABLE = "stable"
  87. UNSTABLE = "unstable"
  88. # the version we will give rooms which are created on this server
  89. DEFAULT_ROOM_VERSION = RoomVersions.V1
  90. # vdh-test-version is a placeholder to get room versioning support working and tested
  91. # until we have a working v2.
  92. KNOWN_ROOM_VERSIONS = {
  93. RoomVersions.V1,
  94. RoomVersions.V2,
  95. RoomVersions.V3,
  96. RoomVersions.STATE_V2_TEST,
  97. RoomVersions.V3,
  98. }
  99. class EventFormatVersions(object):
  100. """This is an internal enum for tracking the version of the event format,
  101. independently from the room version.
  102. """
  103. V1 = 1
  104. V2 = 2
  105. KNOWN_EVENT_FORMAT_VERSIONS = {
  106. EventFormatVersions.V1,
  107. EventFormatVersions.V2,
  108. }
  109. ServerNoticeMsgType = "m.server_notice"
  110. ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
  111. class UserTypes(object):
  112. """Allows for user type specific behaviour. With the benefit of hindsight
  113. 'admin' and 'guest' users should also be UserTypes. Normal users are type None
  114. """
  115. SUPPORT = "support"
  116. ALL_USER_TYPES = (SUPPORT,)