summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2019-01-30 10:23:26 +0000
committerNeil Johnson <neil@matrix.org>2019-01-30 10:23:26 +0000
commit9c850d9d5e83c91cfbc89f978d57ec55b982a1fc (patch)
treeca5e2f669c27d8a1bf2c5f8237b7e7534ba28984 /synapse/rest
parentPopulate default room version from Constants (diff)
downloadsynapse-9c850d9d5e83c91cfbc89f978d57ec55b982a1fc.tar.xz
formatting and use constants where available
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/client/v2_alpha/capabilities.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/synapse/rest/client/v2_alpha/capabilities.py b/synapse/rest/client/v2_alpha/capabilities.py
index 21e79f9233..de3cf2b072 100644
--- a/synapse/rest/client/v2_alpha/capabilities.py
+++ b/synapse/rest/client/v2_alpha/capabilities.py
@@ -16,7 +16,8 @@ import logging
 
 from twisted.internet import defer
 
-from synapse.api.constants import DEFAULT_ROOM_VERSION
+from synapse.api.constants import DEFAULT_ROOM_VERSION, RoomVersions, RoomDisposition
+
 from synapse.http.servlet import RestServlet
 
 from ._base import client_v2_patterns
@@ -43,26 +44,23 @@ class CapabilitiesRestServlet(RestServlet):
     def on_GET(self, request):
         requester = yield self.auth.get_user_by_req(request, allow_guest=True)
         user = yield self.store.get_user_by_id(requester.user.to_string())
-        change_password = bool(user['password_hash'])
+        change_password = bool(user["password_hash"])
 
-        defer.returnValue(
-            (200, {
-                "capabilities": {
-                    "m.room_versions": {
-                        "default": DEFAULT_ROOM_VERSION,
-                        "available": {
-                            "1": "stable",
-                            "2": "stable",
-                            "state-v2-test": "unstable",
-                            "3": "stable",
-                        }
-                    },
-                    "m.change_password": {
-                        "enabled": change_password,
+        response = {
+            "capabilities": {
+                "m.room_versions": {
+                    "default": DEFAULT_ROOM_VERSION,
+                    "available": {
+                        RoomVersions.V1: RoomDisposition.STABLE,
+                        RoomVersions.V2: RoomDisposition.STABLE,
+                        RoomVersions.STATE_V2_TEST: RoomDisposition.UNSTABLE,
+                        RoomVersions.V3: RoomDisposition.STABLE,
                     },
-                }
-            })
-        )
+                },
+                "m.change_password": {"enabled": change_password},
+            }
+        }
+        defer.returnValue((200, response))
 
 
 def register_servlets(hs, http_server):