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

Commit

Permalink
Put ignore_status_msg back and use it in the worker user_syncing method
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkr committed Apr 6, 2022
1 parent 53d2fa4 commit b2a44ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit b2a44ac

Please sign in to comment.