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

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

2026-10-04

Resolve review comments
Some checks failed
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 10s
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Check changed files (pull_request) Successful in 6s
Update flake hashes / update-flake-hashes (pull_request) Successful in 1m21s
Checks / Prek / Pre-commit & Formatting (pull_request) Failing after 1m51s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 8m35s
2026-10-04 23:28:33 +00:00
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-10-04 23:28:33 +00:00
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-10-04 23:28:33 +00:00
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-10-04 23:28:33 +00:00
feat(admin): add admin commands for presence recipients
Adds `!admin debug recalculate-presence-recipients` and
`!admin query get-recipient-users`.
2026-10-04 23:28:33 +00:00
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-10-04 23:28:33 +00:00
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-10-04 23:28:33 +00:00
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-10-04 23:28:33 +00:00