constants.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. # 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. class Membership(object):
  25. """Represents the membership states of a user in a room."""
  26. INVITE = "invite"
  27. JOIN = "join"
  28. KNOCK = "knock"
  29. LEAVE = "leave"
  30. BAN = "ban"
  31. LIST = (INVITE, JOIN, KNOCK, LEAVE, BAN)
  32. class PresenceState(object):
  33. """Represents the presence state of a user."""
  34. OFFLINE = "offline"
  35. UNAVAILABLE = "unavailable"
  36. ONLINE = "online"
  37. class JoinRules(object):
  38. PUBLIC = "public"
  39. KNOCK = "knock"
  40. INVITE = "invite"
  41. PRIVATE = "private"
  42. class LoginType(object):
  43. PASSWORD = "m.login.password"
  44. EMAIL_IDENTITY = "m.login.email.identity"
  45. MSISDN = "m.login.msisdn"
  46. RECAPTCHA = "m.login.recaptcha"
  47. TERMS = "m.login.terms"
  48. DUMMY = "m.login.dummy"
  49. # Only for C/S API v1
  50. APPLICATION_SERVICE = "m.login.application_service"
  51. SHARED_SECRET = "org.matrix.login.shared_secret"
  52. class EventTypes(object):
  53. Member = "m.room.member"
  54. Create = "m.room.create"
  55. Tombstone = "m.room.tombstone"
  56. JoinRules = "m.room.join_rules"
  57. PowerLevels = "m.room.power_levels"
  58. Aliases = "m.room.aliases"
  59. Redaction = "m.room.redaction"
  60. ThirdPartyInvite = "m.room.third_party_invite"
  61. Encryption = "m.room.encryption"
  62. RelatedGroups = "m.room.related_groups"
  63. RoomHistoryVisibility = "m.room.history_visibility"
  64. CanonicalAlias = "m.room.canonical_alias"
  65. Encryption = "m.room.encryption"
  66. RoomAvatar = "m.room.avatar"
  67. RoomEncryption = "m.room.encryption"
  68. GuestAccess = "m.room.guest_access"
  69. # These are used for validation
  70. Message = "m.room.message"
  71. Topic = "m.room.topic"
  72. Name = "m.room.name"
  73. ServerACL = "m.room.server_acl"
  74. Pinned = "m.room.pinned_events"
  75. class RejectedReason(object):
  76. AUTH_ERROR = "auth_error"
  77. REPLACED = "replaced"
  78. NOT_ANCESTOR = "not_ancestor"
  79. class RoomCreationPreset(object):
  80. PRIVATE_CHAT = "private_chat"
  81. PUBLIC_CHAT = "public_chat"
  82. TRUSTED_PRIVATE_CHAT = "trusted_private_chat"
  83. class ThirdPartyEntityKind(object):
  84. USER = "user"
  85. LOCATION = "location"
  86. ServerNoticeMsgType = "m.server_notice"
  87. ServerNoticeLimitReached = "m.server_notice.usage_limit_reached"
  88. class UserTypes(object):
  89. """Allows for user type specific behaviour. With the benefit of hindsight
  90. 'admin' and 'guest' users should also be UserTypes. Normal users are type None
  91. """
  92. SUPPORT = "support"
  93. BOT = "bot"
  94. ALL_USER_TYPES = (SUPPORT, BOT)
  95. class RelationTypes(object):
  96. """The types of relations known to this server.
  97. """
  98. ANNOTATION = "m.annotation"
  99. REPLACE = "m.replace"
  100. REFERENCE = "m.reference"