diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-10-26 15:11:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 15:11:24 -0400 |
commit | 85e5f2dc252b866d67c8da2ddbfdb84974db1807 (patch) | |
tree | 938cdcc69d4c926e6a46361df894c087a73bbbfa /tests/rest/client | |
parent | Convert simple_select_list and simple_select_list_txn to return lists of tupl... (diff) | |
download | synapse-85e5f2dc252b866d67c8da2ddbfdb84974db1807.tar.xz |
Add a new module API to update user presence state. (#16544)
This adds a module API which allows a module to update a user's presence state/status message. This is useful for controlling presence from an external system. To fully control presence from the module the presence.enabled config parameter gains a new state of "untracked" which disables internal tracking of presence changes via user actions, etc. Only updates from the module will be persisted and sent down sync properly).
Diffstat (limited to 'tests/rest/client')
-rw-r--r-- | tests/rest/client/test_presence.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/rest/client/test_presence.py b/tests/rest/client/test_presence.py index 66b387cea3..4e89107e54 100644 --- a/tests/rest/client/test_presence.py +++ b/tests/rest/client/test_presence.py @@ -50,7 +50,7 @@ class PresenceTestCase(unittest.HomeserverTestCase): PUT to the status endpoint with use_presence enabled will call set_state on the presence handler. """ - self.hs.config.server.use_presence = True + self.hs.config.server.presence_enabled = True body = {"presence": "here", "status_msg": "beep boop"} channel = self.make_request( @@ -63,7 +63,22 @@ class PresenceTestCase(unittest.HomeserverTestCase): @unittest.override_config({"use_presence": False}) def test_put_presence_disabled(self) -> None: """ - PUT to the status endpoint with use_presence disabled will NOT call + PUT to the status endpoint with presence disabled will NOT call + set_state on the presence handler. + """ + + body = {"presence": "here", "status_msg": "beep boop"} + channel = self.make_request( + "PUT", "/presence/%s/status" % (self.user_id,), body + ) + + self.assertEqual(channel.code, HTTPStatus.OK) + self.assertEqual(self.presence_handler.set_state.call_count, 0) + + @unittest.override_config({"presence": {"enabled": "untracked"}}) + def test_put_presence_untracked(self) -> None: + """ + PUT to the status endpoint with presence untracked will NOT call set_state on the presence handler. """ |