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

Send to-device messages to application services #11215

Merged
merged 49 commits into from
Feb 1, 2022

Commits on Nov 16, 2021

  1. Configuration menu
    Copy the full SHA
    7fbfedb View commit details
    Browse the repository at this point in the history
  2. Add a new ephemeral AS handler for to_device message edus

    Here we add the ability for the application service ephemeral message
    processor to handle new events on the "to_device" stream.
    
    We keep track of a stream id (token) per application service, and every
    time a new to-device message comes in, for each appservice we pull the
    messages between the last-recorded and current stream id and check
    whether any of the messages are for a user in that appservice's user
    namespace.
    
    get_new_messages is implemented in the next commit.
    
    since we rebased off latest develop.
    anoadragon453 committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    b7a44d4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    78bd5ea View commit details
    Browse the repository at this point in the history
  4. Add database method to fetch to-device messages by user_ids from db

    This method is quite similar to the one below, except that it doesn't
    support device ids, and supports querying with more than one user id,
    both of which are relevant to application services.
    
    The results are also formatted in a different data structure, so I'm
    not sure how much we could really share here between the two methods.
    anoadragon453 committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    7899f82 View commit details
    Browse the repository at this point in the history
  5. Add a to_device_stream_id column to the application_services_state table

    This is for tracking the stream id that each application service has
    been sent up to. In other words, there shouldn't be any need to process
    stream ids below the recorded one here as the AS should have already
    received them.
    
    Note that there is no reliability built-in here. Reliability of delivery
    if intended for a separate PR.
    anoadragon453 committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    103f410 View commit details
    Browse the repository at this point in the history
  6. Add tests

    I decided to spin up another test class for this as the existing one is
    1. quite old and 2. was mocking away too much of the infrastructure to
    my liking. I've named the new class alluding to ephemeral messages, and
    while we already have some ephemeral tests in AppServiceHandlerTestCase,
    ideally I'd like to migrate those over.
    
    There's two new tests here. One for testing that to-device messages for
    a local user are received by any application services that have
    registered interest in that user - and that those that haven't won't
    receive those messages.
    
    The next test is similar, but tests with a whole bunch of to-device
    messages. Rather than actually registering tons of devices - which would
    make for a very slow unit test - we just directly insert them into the
    database.
    anoadragon453 committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    e914f1d View commit details
    Browse the repository at this point in the history
  7. Changelog

    anoadragon453 committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    2930fe6 View commit details
    Browse the repository at this point in the history

Commits on Nov 19, 2021

  1. Make msc2409_to_device_messages_enabled private; remove unnecessary c…

    …heck
    
    The second check for self._msc2409_to_device_messages_enabled was not necessary. It's
    already checked in notify_interested_services_ephemeral earlier.
    anoadragon453 committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    f65846b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ce020c3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8f1183c View commit details
    Browse the repository at this point in the history
  4. Deduplicate ephemeral events to send conditional

    Test cases needed to be updated, as we now always call
    submit_ephemeral_events_for_as, it may just be with an
    empty events list.
    anoadragon453 committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    401cb2b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    179dd5a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    8b0bbc1 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    31c4b40 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    bd9d963 View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2021

  1. Fix existing unit tests

    There is so much mocking going on here. I look forward to replacing these one day.
    anoadragon453 committed Nov 22, 2021
    Configuration menu
    Copy the full SHA
    8f8226a View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2021

  1. Configuration menu
    Copy the full SHA
    b4a4b45 View commit details
    Browse the repository at this point in the history
  2. Add some FIXME comments

    anoadragon453 committed Nov 24, 2021
    Configuration menu
    Copy the full SHA
    c691ef0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7cf6ad9 View commit details
    Browse the repository at this point in the history

Commits on Dec 3, 2021

  1. Refactor and generalise the sending of arbitrary fields over AS trans…

    …actions
    
    Things were starting to get a little inflexible as we kept adding new
    types of data to send to application services. It's better to just
    have one method for adding data to AS transactions, than one for
    each type of data.
    
    Note that subsequent PRs will need to add device lists, one-time keys
    and fallback keys to these transactions. Adding those are additional
    arguments to a method is much nicer than a new method for each one.
    
    Plus with this setup we can add multiple different types of data at
    once without kicking off an AS transaction for each type. This will
    be useful for OTK/fallback keys, as we plan to lazily attach those
    when handling other event types.
    anoadragon453 committed Dec 3, 2021
    Configuration menu
    Copy the full SHA
    6d68b8a View commit details
    Browse the repository at this point in the history
  2. Fix tests to mock _TransactionController.send of ApplicationServiceSc…

    …heduler.enqueue*
    
    With enqueue_for_appservice being called per-event per-appservice, it's
    not a great target for mocking. So we use _TransactionController.send
    instead, to track things that are actually sent out to AS's.
    
    This also has the benefit of testing a wider bit of the AS txn pipeline
    anoadragon453 committed Dec 3, 2021
    Configuration menu
    Copy the full SHA
    13b25cf View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    275e1e0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    403490d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    385b3bf View commit details
    Browse the repository at this point in the history

Commits on Dec 7, 2021

  1. Configuration menu
    Copy the full SHA
    c0b157d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ba91438 View commit details
    Browse the repository at this point in the history

Commits on Jan 11, 2022

  1. Update synapse/storage/schema/main/delta/65/06_msc2409_add_device_id_…

    …appservice_stream_type.sql
    
    Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
    anoadragon453 and richvdh authored Jan 11, 2022
    Configuration menu
    Copy the full SHA
    0685021 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e7f6732 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3d1661f View commit details
    Browse the repository at this point in the history
  4. lint

    anoadragon453 committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    0ac079b View commit details
    Browse the repository at this point in the history

Commits on Jan 25, 2022

  1. Refactor storage methods to retrieve to-device messages

    This commit refactors the previously rather duplicated 'get_new_messages_for_device' and
    'get_new_messages' methods into one new private method with combined logic, and two small
    public methods. The public methods expose the correct interface for querying to-device
    messages for either a single device (where a limit can be used) and multiple devices
    (where using a limit is infeasible).
    anoadragon453 committed Jan 25, 2022
    Configuration menu
    Copy the full SHA
    822e92a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    25488fa View commit details
    Browse the repository at this point in the history

Commits on Jan 26, 2022

  1. Configuration menu
    Copy the full SHA
    026cb8a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1121674 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8129657 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    de48ab4 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d8b8f74 View commit details
    Browse the repository at this point in the history

Commits on Jan 28, 2022

  1. Configuration menu
    Copy the full SHA
    ced1314 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c749fcb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    24512fb View commit details
    Browse the repository at this point in the history
  4. Clean up limit checking

    anoadragon453 committed Jan 28, 2022
    Configuration menu
    Copy the full SHA
    24bc3c5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    30b74a5 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    80c3721 View commit details
    Browse the repository at this point in the history
  7. wording fixes

    anoadragon453 committed Jan 28, 2022
    Configuration menu
    Copy the full SHA
    3d8e50d View commit details
    Browse the repository at this point in the history
  8. Apply suggestions from code review

    Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
    anoadragon453 and richvdh authored Jan 28, 2022
    Configuration menu
    Copy the full SHA
    50ebcb9 View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2022

  1. Configuration menu
    Copy the full SHA
    089e041 View commit details
    Browse the repository at this point in the history

Commits on Feb 1, 2022

  1. Apply suggestions from code review

    Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
    anoadragon453 and richvdh authored Feb 1, 2022
    Configuration menu
    Copy the full SHA
    d06781e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c334eef View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bf93ec4 View commit details
    Browse the repository at this point in the history