This commit is contained in:
Will Hunt 2019-07-11 15:36:57 +01:00
parent deff332951
commit f62000f308
4 changed files with 19 additions and 26 deletions

View file

@ -48,7 +48,6 @@ class PresenceStatusRestServlet(RestServlet):
if not self.hs.config.use_presence:
raise AuthError(403, "Presence is disabled on this homeserver")
if requester.user != user:
allowed = yield self.presence_handler.is_visible(
observed_user=user, observer_user=requester.user

View file

@ -58,7 +58,7 @@ class CapabilitiesRestServlet(RestServlet):
"m.change_password": {"enabled": change_password},
"m.presence": {
"send_enabled": self.config.use_presence,
"receive_enabled": self.config.use_presence
"receive_enabled": self.config.use_presence,
},
}
}

View file

@ -69,10 +69,13 @@ class PresenceTestCase(unittest.HomeserverTestCase):
self.render(request)
self.assertEqual(channel.code, 403)
self.assertEqual({
"errcode": "M_FORBIDDEN",
"error": "Presence is disabled on this homeserver"
}, channel.json_body)
self.assertEqual(
{
"errcode": "M_FORBIDDEN",
"error": "Presence is disabled on this homeserver"
},
channel.json_body,
)
self.assertEqual(self.hs.presence_handler.set_state.call_count, 0)
def test_get_presence_disabled(self):
@ -88,7 +91,10 @@ class PresenceTestCase(unittest.HomeserverTestCase):
self.render(request)
self.assertEqual(channel.code, 403)
self.assertEqual({
"errcode": "M_FORBIDDEN",
"error": "Presence is disabled on this homeserver"
}, channel.json_body)
self.assertEqual(
{
"errcode": "M_FORBIDDEN",
"error": "Presence is disabled on this homeserver"
},
channel.json_body,
)

View file

@ -90,14 +90,8 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
capabilities = channel.json_body["capabilities"]
self.assertEqual(channel.code, 200)
self.assertEqual(
True,
capabilities["m.presence"]["send_enabled"],
)
self.assertEqual(
True,
capabilities["m.presence"]["receive_enabled"],
)
self.assertEqual(True, capabilities["m.presence"]["send_enabled"])
self.assertEqual(True, capabilities["m.presence"]["receive_enabled"])
self.hs.get_config().use_presence = False
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"]
self.assertEqual(channel.code, 200)
self.assertEqual(
False,
capabilities["m.presence"]["send_enabled"],
)
self.assertEqual(
False,
capabilities["m.presence"]["receive_enabled"],
)
self.assertEqual(False, capabilities["m.presence"]["send_enabled"])
self.assertEqual(False, capabilities["m.presence"]["receive_enabled"])