mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-19 17:56:19 +03:00
Linting
This commit is contained in:
parent
deff332951
commit
f62000f308
4 changed files with 19 additions and 26 deletions
|
@ -48,7 +48,6 @@ class PresenceStatusRestServlet(RestServlet):
|
||||||
if not self.hs.config.use_presence:
|
if not self.hs.config.use_presence:
|
||||||
raise AuthError(403, "Presence is disabled on this homeserver")
|
raise AuthError(403, "Presence is disabled on this homeserver")
|
||||||
|
|
||||||
|
|
||||||
if requester.user != user:
|
if requester.user != user:
|
||||||
allowed = yield self.presence_handler.is_visible(
|
allowed = yield self.presence_handler.is_visible(
|
||||||
observed_user=user, observer_user=requester.user
|
observed_user=user, observer_user=requester.user
|
||||||
|
|
|
@ -58,7 +58,7 @@ class CapabilitiesRestServlet(RestServlet):
|
||||||
"m.change_password": {"enabled": change_password},
|
"m.change_password": {"enabled": change_password},
|
||||||
"m.presence": {
|
"m.presence": {
|
||||||
"send_enabled": self.config.use_presence,
|
"send_enabled": self.config.use_presence,
|
||||||
"receive_enabled": self.config.use_presence
|
"receive_enabled": self.config.use_presence,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,13 @@ class PresenceTestCase(unittest.HomeserverTestCase):
|
||||||
self.render(request)
|
self.render(request)
|
||||||
|
|
||||||
self.assertEqual(channel.code, 403)
|
self.assertEqual(channel.code, 403)
|
||||||
self.assertEqual({
|
self.assertEqual(
|
||||||
"errcode": "M_FORBIDDEN",
|
{
|
||||||
"error": "Presence is disabled on this homeserver"
|
"errcode": "M_FORBIDDEN",
|
||||||
}, channel.json_body)
|
"error": "Presence is disabled on this homeserver"
|
||||||
|
},
|
||||||
|
channel.json_body,
|
||||||
|
)
|
||||||
self.assertEqual(self.hs.presence_handler.set_state.call_count, 0)
|
self.assertEqual(self.hs.presence_handler.set_state.call_count, 0)
|
||||||
|
|
||||||
def test_get_presence_disabled(self):
|
def test_get_presence_disabled(self):
|
||||||
|
@ -88,7 +91,10 @@ class PresenceTestCase(unittest.HomeserverTestCase):
|
||||||
self.render(request)
|
self.render(request)
|
||||||
|
|
||||||
self.assertEqual(channel.code, 403)
|
self.assertEqual(channel.code, 403)
|
||||||
self.assertEqual({
|
self.assertEqual(
|
||||||
"errcode": "M_FORBIDDEN",
|
{
|
||||||
"error": "Presence is disabled on this homeserver"
|
"errcode": "M_FORBIDDEN",
|
||||||
}, channel.json_body)
|
"error": "Presence is disabled on this homeserver"
|
||||||
|
},
|
||||||
|
channel.json_body,
|
||||||
|
)
|
||||||
|
|
|
@ -90,14 +90,8 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
||||||
capabilities = channel.json_body["capabilities"]
|
capabilities = channel.json_body["capabilities"]
|
||||||
self.assertEqual(channel.code, 200)
|
self.assertEqual(channel.code, 200)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(True, capabilities["m.presence"]["send_enabled"])
|
||||||
True,
|
self.assertEqual(True, capabilities["m.presence"]["receive_enabled"])
|
||||||
capabilities["m.presence"]["send_enabled"],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
True,
|
|
||||||
capabilities["m.presence"]["receive_enabled"],
|
|
||||||
)
|
|
||||||
|
|
||||||
self.hs.get_config().use_presence = False
|
self.hs.get_config().use_presence = False
|
||||||
request, channel = self.make_request("GET", self.url, access_token=access_token)
|
request, channel = self.make_request("GET", self.url, access_token=access_token)
|
||||||
|
@ -105,11 +99,5 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
||||||
capabilities = channel.json_body["capabilities"]
|
capabilities = channel.json_body["capabilities"]
|
||||||
self.assertEqual(channel.code, 200)
|
self.assertEqual(channel.code, 200)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(False, capabilities["m.presence"]["send_enabled"])
|
||||||
False,
|
self.assertEqual(False, capabilities["m.presence"]["receive_enabled"])
|
||||||
capabilities["m.presence"]["send_enabled"],
|
|
||||||
)
|
|
||||||
self.assertEqual(
|
|
||||||
False,
|
|
||||||
capabilities["m.presence"]["receive_enabled"],
|
|
||||||
)
|
|
Loading…
Reference in a new issue