summary refs log tree commit diff
path: root/synapse/api/errors.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-07-25 22:25:41 +0100
committerRichard van der Hoff <richard@matrix.org>2018-08-03 16:08:32 +0100
commit0d63d93ca834771324f0c5b9340346ad2113a4b1 (patch)
treea76a1d817b4f60034ca7cc7e7b3b6bc308189ff8 /synapse/api/errors.py
parentBasic support for room versioning (diff)
downloadsynapse-0d63d93ca834771324f0c5b9340346ad2113a4b1.tar.xz
Enforce compatibility when processing make_join requests
Reject make_join requests from servers which do not support the room version.

Also include the room version in the response.
Diffstat (limited to 'synapse/api/errors.py')
-rw-r--r--synapse/api/errors.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py
index 477ca07a24..70400347bc 100644
--- a/synapse/api/errors.py
+++ b/synapse/api/errors.py
@@ -58,6 +58,7 @@ class Codes(object):
     CANNOT_LEAVE_SERVER_NOTICE_ROOM = "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM"
     MAU_LIMIT_EXCEEDED = "M_MAU_LIMIT_EXCEEDED"
     UNSUPPORTED_ROOM_VERSION = "M_UNSUPPORTED_ROOM_VERSION"
+    INCOMPATIBLE_ROOM_VERSION = "M_INCOMPATIBLE_ROOM_VERSION"
 
 
 class CodeMessageException(RuntimeError):
@@ -287,6 +288,27 @@ class LimitExceededError(SynapseError):
         )
 
 
+class IncompatibleRoomVersionError(SynapseError):
+    """A server is trying to join a room whose version it does not support."""
+
+    def __init__(self, room_version):
+        super(IncompatibleRoomVersionError, self).__init__(
+            code=400,
+            msg="Your homeserver does not support the features required to "
+                "join this room",
+            errcode=Codes.INCOMPATIBLE_ROOM_VERSION,
+        )
+
+        self._room_version = room_version
+
+    def error_dict(self):
+        return cs_error(
+            self.msg,
+            self.errcode,
+            room_version=self._room_version,
+        )
+
+
 def cs_error(msg, code=Codes.UNKNOWN, **kwargs):
     """ Utility method for constructing an error response for client-server
     interactions.