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

Commits on Mar 25, 2021

  1. Configuration menu
    Copy the full SHA
    de8c33e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    09eb6fd View commit details
    Browse the repository at this point in the history
  3. Add a built-in PresenceRouter class

    This class will perform in the same manner as Synapse did before,
    unless a custom PresenceRouter module is configured. If one is,
    then it will pass through the calls from Synapse to that module.
    anoadragon453 committed Mar 25, 2021
    Configuration menu
    Copy the full SHA
    5751f6d View commit details
    Browse the repository at this point in the history
  4. Modify get_interested_parties and get_interested_remotes to query…

    … PresenceRouter
    
    This commit asks the PresenceRouter for any users - in addition to those
    from users that they share a room with - that should receive the given
    presence updates.
    
    These methods are called when routing new presence updates around as
    they come in.
    
    * `get_interested_parties` is called when figuring out which local and
    remote users to send presence to. For local users, their sync streams
    will be woken up.
    * `get_interested_remotes` is specifically for figuring out which remote
    user(s) a given presence update needs to go to.
    anoadragon453 committed Mar 25, 2021
    Configuration menu
    Copy the full SHA
    3600d63 View commit details
    Browse the repository at this point in the history
  5. Add a func to ModuleApi to send all local online user presence to a s…

    …et of users
    
    This function is useful for 'catching up' a user if you've just starting directing
    presence updates their way. Sending the current presence (excluding offline) for
    each user before you start sending them diffs ensures the target has the right
    presence state for each user immediately.
    
    This effectively just forces a presence initial_sync for the user.
    anoadragon453 committed Mar 25, 2021
    Configuration menu
    Copy the full SHA
    f62e385 View commit details
    Browse the repository at this point in the history
  6. Update PresenceHandler to call PresenceRouter methods when applicable

    This big ol' change does three high-level things:
    
    1. It modifies `_get_interested_in` to ask the loaded PresenceRouter if
    there are any users - in addition to those that share a room with the
    user in question - that it thinks should have their presence status
    queried. PresenceRouter can either return a Set of users, or "ALL".
    
    2. It modifies `get_new_events` (which is mainly run when a user is
    syncing and needs to check for presence updates) to support receiving
    "ALL" from `_get_interested_in`. What happens then depends on whether a
    `from_key` was provided to `get_new_events`. We also now call
    `get_users_and_states` to filter the UserPresenceState objects after
    querying ALL of them from a given `from_key`.
    
    3. It also modifies `get_new_events` to take into account whether the
    syncing user is included in
    `ModuleApi.send_full_presence_to_local_users`. If so, then we're going
    to send them all current user presence state (filtering it through
    `get_users_for_states` again). We then remove the user ID from the set
    to ensure the same doesn't happen on the next sync.
    
    This is mainly all to support redirecting presence for local users as
    they sync, though the same method is called for appservice users.
    anoadragon453 committed Mar 25, 2021
    Configuration menu
    Copy the full SHA
    2a0c785 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    08f39cf View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    5c5eb45 View commit details
    Browse the repository at this point in the history
  9. Changelog

    anoadragon453 committed Mar 25, 2021
    Configuration menu
    Copy the full SHA
    ff6d051 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    b67b071 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    41f9cd1 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    5fc716c View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a2a60e0 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    997a81b View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    41537b9 View commit details
    Browse the repository at this point in the history

Commits on Mar 26, 2021

  1. Configuration menu
    Copy the full SHA
    4fcd817 View commit details
    Browse the repository at this point in the history
  2. typo fix

    Co-authored-by: Erik Johnston <erik@matrix.org>
    anoadragon453 and erikjohnston authored Mar 26, 2021
    Configuration menu
    Copy the full SHA
    744bb53 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6daf640 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5e2a047 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    37d30d7 View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2021

  1. Configuration menu
    Copy the full SHA
    1dfc8cc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    42a7db2 View commit details
    Browse the repository at this point in the history
  3. presence != federation

    anoadragon453 committed Mar 29, 2021
    Configuration menu
    Copy the full SHA
    23c5b93 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7c1eedb View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2021

  1. Configuration menu
    Copy the full SHA
    5549f52 View commit details
    Browse the repository at this point in the history
  2. Wording fixes

    anoadragon453 committed Mar 31, 2021
    Configuration menu
    Copy the full SHA
    6fae9f3 View commit details
    Browse the repository at this point in the history
  3. Refactor _filter_all_presence_updates_for_user; always filter through PR

    This commit refactors _filter_all_presence_updates_for_user a little bit to allow
    taking from_key as an optional parameter. The advantage of this function is that
    we filter presence updates through PresenceRouter. Turns out we had a code path
    (no from_key, return presence for ALL users) that ended up not filtering through
    PresenceRouter.
    
    Having both code paths end in _filter_all_presence_updates_for_user not only makes
    things a little easier to follow, but it ensures filtering always happens.
    
    I also took the bit where we remove the user from
    ModuleApi.send_full_presence_to_local_users out of
    _filter_all_presence_updates_for_user to clean it up a bit further.
    anoadragon453 committed Mar 31, 2021
    Configuration menu
    Copy the full SHA
    2f16ed0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    36a7bd2 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9186191 View commit details
    Browse the repository at this point in the history

Commits on Apr 1, 2021

  1. Move PresenceRouter module_api test to test_presence_router

    This test was more concerned with the functionality of PresenceRouter, so I moved it
    to the PresenceRouter test file instead.
    anoadragon453 committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    ac4b0ff View commit details
    Browse the repository at this point in the history
  2. Refactor PresenceRouter tests

    The current default_config method didn't quite work for the test we just moved in,
    (it negated any use of @override_config). So convert it to an @override_config
    call instead.
    anoadragon453 committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    6e42612 View commit details
    Browse the repository at this point in the history
  3. Sort some eyes

    anoadragon453 committed Apr 1, 2021
    Configuration menu
    Copy the full SHA
    25de4c1 View commit details
    Browse the repository at this point in the history

Commits on Apr 6, 2021

  1. Configuration menu
    Copy the full SHA
    a1a52f4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e538126 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9ddbaa8 View commit details
    Browse the repository at this point in the history