feat: implement optional support for MSC4495 (Selective Presence) #2034

Open
thetayloredman wants to merge 11 commits from thetayloredman/continuwuity:presence-v2/msc4495 into main

11 commits

Author SHA1 Message Date
329f491c9e
chore: address CI failure and code review comment
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Check changed files (pull_request) Successful in 6s
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 9s
Checks / Prek / Pre-commit & Formatting (pull_request) Failing after 1m9s
Update flake hashes / update-flake-hashes (pull_request) Successful in 1m24s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 5m36s
2026-09-05 17:26:35 -07:00
8a405c9908
chore: add changelog fragment 2026-09-05 17:26:34 -07:00
3df16ecabc
feat: handle outbound Selective Presence
This commit moves responsibility for sending presence EDUs out of the
sender's `select_edus_presence` function, and instead to a push approach
from the presence module. Upon `set_presence` for a local user, the presence
module calculates the user's recipient set (if selective presence is enabled)
and then applies that information to outbound presence EDUs.
2026-09-05 17:26:34 -07:00
0009bad90e
feat: use presence recipient lists to restrict presence access
This commit applies recipient lists as access control to presence down `/sync`
and the `/client/users/{userId}/status` endpoint.
2026-09-05 17:26:34 -07:00
14ef1cbc02
feat: handle presence recipients on inbound EDUs 2026-09-05 17:26:33 -07:00
01a89f7f56
feat: add presence sharing hint to room creation template 2026-09-05 17:26:33 -07:00
5c4ea33e81
feat: add MSC4495 /query/presence_recipients federation endpoint
Adds the `presence_recipients` federation query endpoint, used by remote
servers to query the recipients of a local user in the case of a break
in the stream of EDU updates.
2026-09-05 17:26:33 -07:00
388dfe250d
feat(admin): add admin commands for presence recipients
Adds `!admin debug recalculate-presence-recipients` and
`!admin query get-recipient-users`.
2026-09-05 17:26:32 -07:00
f90254465a
feat: add MSC4495 recipient user set calculation
This commit adds logic for MSC4495 to the presence module, specifically
calculating a user's desired recipient user set given their `m.presence.sharing`
account_data alongside hints in rooms they are a member of.
2026-09-05 17:26:32 -07:00
652d829d9e
chore(database): add MSC4495 userid_recipients column and data model
This commit adds the MSC4495 `userid_recipients` column, along with
the `PresenceRecipients` type and utilities.

For local users, this stores the user's most recently sent presence
recipients stream, and all remote and local users in their recipients set.

For remote users, this stores all local users in the recipient set as of
the last received presence EDU.

Additionally, utility functions for calculating and applying updates
are added.
2026-09-05 17:26:31 -07:00
33b00d0e8e
chore: add MSC4495 config option, make unstable feature optional
This commit adds the config option `enable_msc4495_selective_presence`,
which will allow server operators to toggle MSC4495 before it is merged
into the spec. As this proposal is likely to break people's workflow up
until clients adequately support it, this gate is enabled for now.

We also pave the framework for future optional MSCs, by allowing the
`unstable_features()` function to take in a `Config` instance. This is
also propagated to callsites where it is used for path building by Ruma.
2026-09-05 17:26:31 -07:00