matrix-sdk: Ensure correct room for events loaded by chunks #8168
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Chunks should not load events from other rooms if they happen to be requested for one eventId that already exists in a different room.
Type of change
Content
Always check for correct roomId when loading events from chunks.
Motivation and context
Motivation from a client that renders rich replies (although the broken scenario can most likely appear in other cases as well, may be less severe):
If somebody links an invalid eventId in a room, which however is valid in a different room, this can mess up our timelines badly. This can be reproduced by replying to an event in a room, then forward the reply to a different room with a client that also forwards the replied-to information (such as FluffyChat - likely a bug though). Then click on the rich reply to open the eventId. Previously, Android could find the event from the other room and thus replace the correct timeline with the wrong one.
Together with the feature to always open the timeline at the last read event, this can persistently replace the timeline of one room with the wrong one.
Compare e.g. https://matrix.to/#/!bfebJVBOZMnORmkVdO:matrix.org/$wUyRiMQEjaWOpJ-XpdBJzuXkh95N7bce2pVT4IMXW50?via=schildi.chat&via=matrix.org&via=envs.net linking to an event that exists here
https://matrix.to/#/!SDwMepdfgrmExhyxYZ:schildi.chat/$MO2G4MZZ1zg0Ymc9gTfekIyw7QFkNn4OvYQKK1PAGlE
Tests
See motivation.
Tested devices
Checklist
Sign-off
Signed-off-by: Tobias Büttner [email protected]