formatting and use constants where available
This commit is contained in:
parent
2f46804055
commit
9c850d9d5e
|
@ -16,7 +16,8 @@ import logging
|
||||||
|
|
||||||
from twisted.internet import defer
|
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 synapse.http.servlet import RestServlet
|
||||||
|
|
||||||
from ._base import client_v2_patterns
|
from ._base import client_v2_patterns
|
||||||
|
@ -43,26 +44,23 @@ class CapabilitiesRestServlet(RestServlet):
|
||||||
def on_GET(self, request):
|
def on_GET(self, request):
|
||||||
requester = yield self.auth.get_user_by_req(request, allow_guest=True)
|
requester = yield self.auth.get_user_by_req(request, allow_guest=True)
|
||||||
user = yield self.store.get_user_by_id(requester.user.to_string())
|
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(
|
response = {
|
||||||
(200, {
|
"capabilities": {
|
||||||
"capabilities": {
|
"m.room_versions": {
|
||||||
"m.room_versions": {
|
"default": DEFAULT_ROOM_VERSION,
|
||||||
"default": DEFAULT_ROOM_VERSION,
|
"available": {
|
||||||
"available": {
|
RoomVersions.V1: RoomDisposition.STABLE,
|
||||||
"1": "stable",
|
RoomVersions.V2: RoomDisposition.STABLE,
|
||||||
"2": "stable",
|
RoomVersions.STATE_V2_TEST: RoomDisposition.UNSTABLE,
|
||||||
"state-v2-test": "unstable",
|
RoomVersions.V3: RoomDisposition.STABLE,
|
||||||
"3": "stable",
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"m.change_password": {
|
},
|
||||||
"enabled": change_password,
|
"m.change_password": {"enabled": change_password},
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
})
|
defer.returnValue((200, response))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def register_servlets(hs, http_server):
|
def register_servlets(hs, http_server):
|
||||||
|
|
Loading…
Reference in New Issue