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

Add a Synapse Module for configuring presence update routing #9491

Merged
merged 35 commits into from
Apr 6, 2021
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
de8c33e
Add documentation for implementing a PresenceRouter module
anoadragon453 Mar 17, 2021
09eb6fd
Clean up presence config, allow specifying a presence_router module
anoadragon453 Mar 17, 2021
5751f6d
Add a built-in PresenceRouter class
anoadragon453 Mar 17, 2021
3600d63
Modify `get_interested_parties` and `get_interested_remotes` to query…
anoadragon453 Mar 18, 2021
f62e385
Add a func to ModuleApi to send all local online user presence to a s…
anoadragon453 Mar 17, 2021
2a0c785
Update PresenceHandler to call PresenceRouter methods when applicable
anoadragon453 Mar 18, 2021
08f39cf
Update method calls to thread presence_router through to presence han…
anoadragon453 Mar 18, 2021
5c5eb45
Add tests for PresenceRouter and new module_api method
anoadragon453 Mar 18, 2021
ff6d051
Changelog
anoadragon453 Mar 18, 2021
b67b071
Remove Literal as it's broken on py35-olddeps
anoadragon453 Mar 18, 2021
41f9cd1
Social distancing for example module
anoadragon453 Mar 22, 2021
5fc716c
Specify PresenceRouter class method definitions up front
anoadragon453 Mar 22, 2021
a2a60e0
Add docstring to (and remove useless arg from) method
anoadragon453 Mar 22, 2021
997a81b
Raise if required PresenceRouter methods are not implemented
anoadragon453 Mar 23, 2021
41537b9
Note that AS's are not currently supported
anoadragon453 Mar 25, 2021
4fcd817
Don't just blindly copy our PoC code
anoadragon453 Mar 26, 2021
744bb53
typo fix
anoadragon453 Mar 26, 2021
6daf640
Add a test for sending all local online presence over federation
anoadragon453 Mar 26, 2021
5e2a047
Fix burst federation presence sending implementation
anoadragon453 Mar 26, 2021
37d30d7
Fix cyclic dependency import
anoadragon453 Mar 26, 2021
1dfc8cc
Only load federation_sender where it's needed in ModuleApi
anoadragon453 Mar 29, 2021
42a7db2
Merge branch 'develop' of github.com:matrix-org/synapse into anoa/pre…
anoadragon453 Mar 29, 2021
23c5b93
presence != federation
anoadragon453 Mar 29, 2021
7c1eedb
Merge branch 'develop' of github.com:matrix-org/synapse into anoa/pre…
anoadragon453 Mar 29, 2021
5549f52
Make "ALL" return value a constant
anoadragon453 Mar 31, 2021
6fae9f3
Wording fixes
anoadragon453 Mar 31, 2021
2f16ed0
Refactor _filter_all_presence_updates_for_user; always filter through PR
anoadragon453 Mar 31, 2021
36a7bd2
Make ModuleApi._send_full_presence_to_local_users private
anoadragon453 Mar 31, 2021
9186191
Add a couple tests for send_local_online_presence_to w/o a PresenceRo…
anoadragon453 Mar 31, 2021
ac4b0ff
Move PresenceRouter module_api test to test_presence_router
anoadragon453 Mar 31, 2021
6e42612
Refactor PresenceRouter tests
anoadragon453 Mar 31, 2021
25de4c1
Sort some eyes
anoadragon453 Apr 1, 2021
a1a52f4
Some clarifications to the module documentation
anoadragon453 Apr 6, 2021
e538126
Clarify text in a comment and docstring
anoadragon453 Apr 6, 2021
9ddbaa8
Merge branch 'develop' of github.com:matrix-org/synapse into anoa/pre…
anoadragon453 Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Specify PresenceRouter class method definitions up front
  • Loading branch information
anoadragon453 committed Mar 25, 2021
commit 5fc716cb9d65a74c37e771a10c0ead79bf58e8a6
49 changes: 49 additions & 0 deletions docs/presence_router_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,55 @@ which can be given a list of local or remote MXIDs to broadcast known, online us
presence to (for those users that the receiving user is considered interested in).
It does not include state for users who are currently offline.

### Module structure

Below is a list of possible methods that can be implemented, and whether they are
required.

#### `parse_config`

```python
def parse_config(config_dict: dict) -> Any
```
**Required.** A static method that is passed a dictionary of config options, and
should return a validated config object. This method is described further in
[Configuration](#configuration).

#### `get_users_for_states`

```python
async def get_users_for_states(
self,
state_updates: Iterable[UserPresenceState],
) -> Dict[str, Set[UserPresenceState]]:
```

An asynchronous class method that is passed an iterable of user presence state. This
method can determine whether a given presence update should be sent to certain users.
It does this by returning a dictionary with keys representing local or remote Matrix
User IDs, and values being a python Set of `synapse.handlers.presence.
UserPresenceState` instances.

Synapse will then attempt to send the specified presence updates to each user when
possible.

#### `get_interested_users`

```python
async def get_interested_users(self, user_id: str) -> Union[Set[str], str]
```

An asynchronous class method that is passed a single Matrix User ID. This method is
expected to return the users that the passed in user may be interested in the presence of.
This may be local or remote users. It does so by returning a python Set of Matrix User
IDs, or the string `"ALL"` to mean that the passed user should receive presence
information for *all* known users.

For clarity, if the user `@alice:example.org` is passed to this method, and the Set
`{"@bob:example.com", "@charlie:somewhere.org"}` is returned, this signifies that Alice
should receive presence updates sent by Bob and Charlie, regardless of whether these
users share a room.

### Example
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved

Below is an example implementation of a presence router class.
Expand Down