constants.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. RoomHistoryVisibility = "m.room.history_visibility"
  58. CanonicalAlias = "m.room.canonical_alias"
  59. RoomAvatar = "m.room.avatar"
  60. GuestAccess = "m.room.guest_access"
  61. # These are used for validation
  62. Message = "m.room.message"
  63. Topic = "m.room.topic"
  64. Name = "m.room.name"
  65. ServerACL = "m.room.server_acl"
  66. Pinned = "m.room.pinned_events"
  67. class RejectedReason(object):
  68. AUTH_ERROR = "auth_error"
  69. REPLACED = "replaced"
  70. NOT_ANCESTOR = "not_ancestor"
  71. class RoomCreationPreset(object):
  72. PRIVATE_CHAT = "private_chat"
  73. PUBLIC_CHAT = "public_chat"
  74. TRUSTED_PRIVATE_CHAT = "trusted_private_chat"
  75. class ThirdPartyEntityKind(object):
  76. USER = "user"
  77. LOCATION = "location"
  78. class RoomVersions(object):
  79. V1 = "1"
  80. V2 = "2"
  81. VDH_TEST = "vdh-test-version"
  82. STATE_V2_TEST = "state-v2-test"
  83. # the version we will give rooms which are created on this server
  84. DEFAULT_ROOM_VERSION = RoomVersions.V1
  85. # vdh-test-version is a placeholder to get room versioning support working and tested
  86. # until we have a working v2.
  87. KNOWN_ROOM_VERSIONS = {
  88. RoomVersions.V1,
  89. RoomVersions.V2,
  90. RoomVersions.VDH_TEST,
  91. RoomVersions.STATE_V2_TEST,
  92. }
  93. ServerNoticeMsgType = "m.server_notice"
  94. ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
  95. class UserTypes(object):
  96. """Allows for user type specific behaviour. With the benefit of hindsight
  97. 'admin' and 'guest' users should also be UserTypes. Normal users are type None
  98. """
  99. SUPPORT = "support"
  100. ALL_USER_TYPES = (SUPPORT,)