diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-08-28 13:08:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-28 13:08:49 -0400 |
commit | 40901af5e096cb10ab69141875b071b4ea4ed1e0 (patch) | |
tree | ddc310741a9c98bda2435b848832f9e3be49bf35 /synapse/replication/http/presence.py | |
parent | Combine logic about not overriding BUSY presence. (#16170) (diff) | |
download | synapse-40901af5e096cb10ab69141875b071b4ea4ed1e0.tar.xz |
Pass the device ID around in the presence handler (#16171)
Refactoring to pass the device ID (in addition to the user ID) through the presence handler (specifically the `user_syncing`, `set_state`, and `bump_presence_active_time` methods and their replication versions).
Diffstat (limited to 'synapse/replication/http/presence.py')
-rw-r--r-- | synapse/replication/http/presence.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/replication/http/presence.py b/synapse/replication/http/presence.py index a24fb9310b..6c9e79fb07 100644 --- a/synapse/replication/http/presence.py +++ b/synapse/replication/http/presence.py @@ -13,7 +13,7 @@ # limitations under the License. import logging -from typing import TYPE_CHECKING, Tuple +from typing import TYPE_CHECKING, Optional, Tuple from twisted.web.server import Request @@ -51,14 +51,14 @@ class ReplicationBumpPresenceActiveTime(ReplicationEndpoint): self._presence_handler = hs.get_presence_handler() @staticmethod - async def _serialize_payload(user_id: str) -> JsonDict: # type: ignore[override] - return {} + async def _serialize_payload(user_id: str, device_id: Optional[str]) -> JsonDict: # type: ignore[override] + return {"device_id": device_id} async def _handle_request( # type: ignore[override] self, request: Request, content: JsonDict, user_id: str ) -> Tuple[int, JsonDict]: await self._presence_handler.bump_presence_active_time( - UserID.from_string(user_id) + UserID.from_string(user_id), content.get("device_id") ) return (200, {}) @@ -95,11 +95,13 @@ class ReplicationPresenceSetState(ReplicationEndpoint): @staticmethod async def _serialize_payload( # type: ignore[override] user_id: str, + device_id: Optional[str], state: JsonDict, force_notify: bool = False, is_sync: bool = False, ) -> JsonDict: return { + "device_id": device_id, "state": state, "force_notify": force_notify, "is_sync": is_sync, @@ -110,6 +112,7 @@ class ReplicationPresenceSetState(ReplicationEndpoint): ) -> Tuple[int, JsonDict]: await self._presence_handler.set_state( UserID.from_string(user_id), + content.get("device_id"), content["state"], content["force_notify"], content.get("is_sync", False), |