Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Prevent a sync request from removing a user's busy presence status #12213

Merged
merged 21 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Put ignore_status_msg back and use it in the worker user_syncing method
  • Loading branch information
dbkr committed Apr 6, 2022
commit b2a44ac41edf82538e93c37efddc16041cb3ab49
13 changes: 9 additions & 4 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ async def set_state(
self,
target_user: UserID,
state: JsonDict,
ignore_status_msg: bool = False,
force_notify: bool = False,
) -> None:
"""Set the presence state of the user.
Expand Down Expand Up @@ -478,9 +479,8 @@ async def user_syncing(

prev_state = await self.current_state_for_user(user_id)
if prev_state != PresenceState.BUSY:
# XXX: Why does this pass force_notify = True? This is copied
# from when the sync rest handler set the presence itself, but
# I don't really understand why this would be necessary.
# We set state here but pass ignore_status_msg = True as we don't want to
# cause the status message to be cleared.
await self.set_state(
UserID.from_string(user_id), {"presence": presence_state}, True
)
Expand Down Expand Up @@ -579,6 +579,7 @@ async def set_state(
self,
target_user: UserID,
state: JsonDict,
ignore_status_msg: bool = False,
force_notify: bool = False,
) -> None:
"""Set the presence state of the user.
Expand Down Expand Up @@ -615,6 +616,7 @@ async def set_state(
instance_name=self._presence_writer_instance,
user_id=user_id,
state=state,
ignore_status_msg=ignore_status_msg,
force_notify=force_notify,
)

Expand Down Expand Up @@ -1179,6 +1181,7 @@ async def set_state(
self,
target_user: UserID,
state: JsonDict,
ignore_status_msg: bool = False,
force_notify: bool = False,
) -> None:
"""Set the presence state of the user.
Expand Down Expand Up @@ -1210,7 +1213,9 @@ async def set_state(
prev_state = await self.current_state_for_user(user_id)

new_fields = {"state": presence}
new_fields["status_msg"] = status_msg

if not ignore_status_msg:
new_fields["status_msg"] = status_msg

if presence == PresenceState.ONLINE or (
presence == PresenceState.BUSY and self._busy_presence_enabled
Expand Down
2 changes: 2 additions & 0 deletions synapse/replication/http/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async def _serialize_payload( # type: ignore[override]
) -> JsonDict:
return {
"state": state,
"ignore_status_msg": ignore_status_msg,
"force_notify": force_notify,
}

Expand All @@ -113,6 +114,7 @@ async def _handle_request( # type: ignore[override]
await self._presence_handler.set_state(
UserID.from_string(user_id),
content["state"],
content["ignore_status_msg"],
content["force_notify"],
)

Expand Down