element-hq / element-hq/synapse
Stuck Notification Badges on Blocked-User Invite
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
### Description
First thing: I've had this issue for YEARS, and thought I would throw Fable at it while it's in it's trial period. I even took a snapshot of my DB and gave it full access (yes, I got a bit desperate). It found the problem (I'm pretty confident because the fix did indeed fix it, I confirmed the block + invite, etc). Below is the clanker text after I asked it to summarize the issue for me:
One way to get a permanently stuck badge: an invite from an ignored user. All sync implementations filter these invites out (`handlers/sliding_sync/room_lists.py` and the equivalent in `handlers/sync.py`), so no client will ever display the invite. But `get_badge_count` in `push/push_tools.py` counts `len(get_invited_rooms_for_local_user(...))` with no ignored-user filtering, so the invite adds +1 to the push badge forever. I confirmed this on my own homeserver (the invite sat hidden for 4.5 years) and cleared it by rejecting the invite via a raw `POST /_matrix/client/v3/rooms/{roomId}/leave` with the room ID pulled from the database.
Anyway, apologies for what amounts to an AI issue, but I felt this was a pretty decent find. I never thought I could be so excited to see a badge notification go away!
### Steps to reproduce
- user A ignores user B
- B invites A to a room
- A's badge never reaches zero and nothing in any client explains why
### Homeserver
kulak.us
### Synapse Version
1.153.0
### Installation Method
Docker (matrixdotorg/synapse)
### Database
Postrgres (single server)
### Workers
Single process
### Platform
Docker container running on a NAS. The database runs on a separate machine in the same local network.
### Configuration
No, very vanilla setup.
### Relevant log output
```shell
I don't have anything to share here, sorry.
```
### Anything else that would be useful to know?
_No response_
Contributor guide
Research direction
Start in handlers/sliding_sync/room_lists.py and handlers/sync.py, then inspect get_badge_count in push/push_tools.py and how get_invited_rooms_for_local_user is used. Reproduce the ignored-user invite scenario and verify that the hidden invite no longer keeps the badge count above zero while normal invites still behave as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100