Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeline/sendq: add a Timeline::redact() method and tweak local echoes behavior #3488

Closed
wants to merge 21 commits into from

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented May 31, 2024

Moar changes requested by @stefanceriu, please test :)

  • Add a way to redact an event directly from the timeline. It's more general than Room::redact since it can have an effect on local echoes too.
  • Gets rid of the EventSendState::Cancelled variant, since it's a white lie now that the sending queue automatically retries in the background.
  • Mark local echoes (that have not been sent yet) as not editable, and test this functionality (!).

Part of #3361.

bnjbvr added 18 commits May 31, 2024 14:16
…ground

This implements the following features:

- enabling/disabling the sending queue at a client-wide granularity,
- one sending queue per room, that lives until the client is shutting
down,
- retrying sending an event three times, if it failed in the past, with
some exponential backoff to attempt to re-send,
- allowing to cancel sending an event we haven't sent yet.

fixup sdk
A client would require this to know that the sending queue has been
globally disabled, across all the rooms, otherwise they couldn't know
that it needs to be re-enabled later on.
So as to not use sync mutexes across await points, we have to use an
async mutex, BUT it can't be immediately called in a wiremock responder,
so we need to shoe-horn a bit: create a new tokio runtime, which can
only be called from another running thread, etc. It's a bit ugly, but I
couldn't find another mechanism to block the responder from returning a
Response immediately; happy to change that anytime if there's a simpler
way.
Technically, the test already passed before the change in the builder,
because `TimelineEventHandler::handle_event` already filters out local
events on non-live timelines, but it's a waste of resources to even
spawn the local echo listener task in that case, so let's not do it.
…cal echo

The test relied on the fact that sending an event from a given timeline
is not observable from another timeline. Indeed, it sent a message using
a first timeline object, then constructed a second timeline object and
expected only the remote event to be in there.

Now, the sending queue is shared across all instances of a Room, thus
all instances of a Timeline, and the second timeline can see the local
echo for the message sent by the first timeline.

The "fix" is thus in the test structure itself: when waiting for the
remote echo to be there, check that the timeline item doesn't pertain to
a local echo, i.e. is a remote echo.
It was used after a previous local echo couldn't be sent (i.e. the
sending queue failed to send it). However, it was slightly incorrect to
mark those as cancelled, since those local echoes would still have
corresponding items in the sending queue, and would be retried as soon
as the sending queue was reenabled and could send events.

Instead, this is removed: it means that previously cancelled events
would be in the NotSentYet state, which is correct. (At the limit, we
could even get rid of the SendingFailed variant, since the sending queue
will automatically retry as soon as possible.)
Also reunify two methods that did the same thing, with slightly
different semantics, and test the one that wasn't tested at all.

Note that `is_editable()` was already exposed to the FFI and used in EX
apps.
@bnjbvr bnjbvr force-pushed the bnjbvr/send-q-timeline-improvements branch from 78d5984 to 84695ad Compare May 31, 2024 12:33
@bnjbvr
Copy link
Member Author

bnjbvr commented Jun 3, 2024

(Closing, #3475 contains all the changes now.)

@bnjbvr bnjbvr closed this Jun 3, 2024
@bnjbvr bnjbvr deleted the bnjbvr/send-q-timeline-improvements branch June 3, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant