element-hq / element-hq/synapse

Status messages aren't included in initial syncs if the sender is offline

Open
#13,507 0 comments 0 reactions 0 assignees View on GitHub
A-Sync O-Uncommon S-Minor T-Defect
Dominant language
Python
Stars
4.6k
Forks
607
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#13507](https://github.com/matrix-org/synapse/issues/13507).

---

This means if a user sets their status message while another user is logged out of all of their devices, that other user won't get the (new) status message. This is causing issues with deployments relying on status messages being distributed reliably.

A fix could be:

```diff
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 741504ba9f..dcca322b56 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -1814,7 +1814,10 @@ class PresenceEventSource(EventSource[int, UserPresenceState]):
return [
update
for update in presence_updates
- if update.state != PresenceState.OFFLINE
+ if (
+ update.state != PresenceState.OFFLINE
+ or update.status_msg
+ )
]

def get_current_key(self) -> int:
```

Though I'm not fully sure of the performance implications and what it would mean in terms of the increase in the size of initial sync responses.

We could technically add a configuration setting to switch to this behaviour but it doesn't sound like the right solution to me.

Contributor guide

Open the contributing guide

Research direction

Start in synapse/handlers/presence.py at PresenceEventSource and its filtering of presence_updates for initial syncs. Trace how offline users' status messages are handled, then verify that a status message set while the recipient is offline is included when they reconnect. Check the performance and initial-sync response-size implications before considering the issue done.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.