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

Fix requestVerificationDM with chronological pendingEventOrdering #1943

Merged
merged 2 commits into from
Oct 14, 2021

Conversation

freaktechnik
Copy link
Contributor

@freaktechnik freaktechnik commented Sep 21, 2021

Signed-off-by: Martin Giger martin@humanoids.be

This PR is the result of an issue I ran into while implementing user verification for Thunderbird. I'm not sure this is the correct way to handle the chronological timeline case, but it makes sure that the handler won't run with an unsent temporary event ID, and thus assuming the wrong transaction ID.

CC @uhoreg


Here's what your changelog entry will look like:

🐛 Bug Fixes

  • Fix requestVerificationDM with chronological pendingEventOrdering (#1943). Contributed by freaktechnik.

Signed-off-by: Martin Giger <martin@humanoids.be>
@freaktechnik freaktechnik requested a review from a team as a code owner September 21, 2021 18:12
@uhoreg
Copy link
Member

uhoreg commented Sep 21, 2021

Thanks for the PR. I think that this almost works, but not quite. If the event status is SENT (the event has been sent to the server, but we haven't received the local echo yet), then isSending will return true, but the event will already have the final event ID, which means that Event.localEventIdReplaced won't get triggered. So I think that it needs to be if (event.isSending() || event.status != EventStatus.SENT) .... Which is, unfortunately, kind of ugly.

src/crypto/index.ts Outdated Show resolved Hide resolved
@freaktechnik
Copy link
Contributor Author

Thanks for the PR. I think that this almost works, but not quite. If the event status is SENT (the event has been sent to the server, but we haven't received the local echo yet), then isSending will return true, but the event will already have the final event ID, which means that Event.localEventIdReplaced won't get triggered. So I think that it needs to be if (event.isSending() || event.status != EventStatus.SENT) .... Which is, unfortunately, kind of ugly.

Based on https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/models/event.ts#L1051 the SDK thinks the ID could still change from the remote echo? Or is that code path irrelevant for events sent by the local session?

@uhoreg
Copy link
Member

uhoreg commented Sep 28, 2021

Yeah, it's a bit confusing there. That event only gets emitted only if this.getId() !== oldId, that is, if the ID actually changes. However, the ID for the event supposed to be set at https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/models/room.ts#L1655 when the status is also set to SENT.

Unfortunately, it looks like it sets the status to SENT before setting the correct event ID, so you can't just listen for the Event.status event, because when it gets triggered, it won't have the right ID yet. So I think you may need to listen to both Event.status and Event.localEventIdReplaced. Resolve on Event.localEventIdReplaced and reject if Event.status gets triggered with a status of CANCELLED.

Copy link
Member

@uhoreg uhoreg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant to look at this earlier. It looks good to me. I'll ask for review from someone else on the web team to check it over, but I think it should basically be ready.

@uhoreg uhoreg requested a review from a team October 12, 2021 17:18
@dbkr dbkr merged commit 0a3d820 into matrix-org:develop Oct 14, 2021
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Oct 25, 2021
* Use `ICallFeedOpts` in the `CallFeed` constructor. To construct a new `CallFeed` object you have to pass `ICallFeedOpts` e.g. `const callFeed = new CallFeed({client ([\matrix-org#1964](matrix-org#1964)). Contributed by [SimonBrandner](https://github.com/SimonBrandner).
* Make threads use 'm.thread' relation ([\matrix-org#1980](matrix-org#1980)).
* Try to answer a call without video if we can't access the camera  ([\matrix-org#1972](matrix-org#1972)). Fixes element-hq/element-web#17975 and element-hq/element-web#17975. Contributed by [SimonBrandner](https://github.com/SimonBrandner).
* Make `opts` in `importRoomKeys()` optional ([\matrix-org#1974](matrix-org#1974)). Contributed by [SimonBrandner](https://github.com/SimonBrandner).
* Enable TypeScript declaration maps ([\matrix-org#1966](matrix-org#1966)). Contributed by [Alexendoo](https://github.com/Alexendoo).
* Fix `requestVerificationDM` with chronological `pendingEventOrdering` ([\matrix-org#1943](matrix-org#1943)). Contributed by [freaktechnik](https://github.com/freaktechnik).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants