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

sdk: don't clobber the DM list if we failed to deserialize the previous m.direct event #3634

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jul 1, 2024

Fixes #3410.

I don't think there's a point in waiting for the m.direct data to come through sync, as 1. it would require a causality link (channel) between getting the m.direct event and this method — not impossible but tedious, and 2. marking a room as DM doesn't occur that often, so there's no need to optimize for it that much.

@bnjbvr bnjbvr requested a review from a team as a code owner July 1, 2024 16:24
@bnjbvr bnjbvr requested review from Hywan and removed request for a team July 1, 2024 16:24
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.22%. Comparing base (263c86b) to head (5662b59).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3634      +/-   ##
==========================================
+ Coverage   84.19%   84.22%   +0.03%     
==========================================
  Files         256      256              
  Lines       26594    26597       +3     
==========================================
+ Hits        22391    22402      +11     
+ Misses       4203     4195       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bnjbvr bnjbvr force-pushed the bnjbvr/dont-clobber-dm-list branch from 3df04a8 to 7bb64ea Compare July 2, 2024 09:12
…us m.direct event

Report a deserialization failure and do not mark the room as a DM,
instead of incorrectly restarting from an empty DM list.

Fixes #3410.
@bnjbvr bnjbvr force-pushed the bnjbvr/dont-clobber-dm-list branch from 7bb64ea to 5662b59 Compare July 2, 2024 09:15
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

It looks good to me. Kudos for the test! Thanks for the fix!

Mock::given(method("GET"))
.and(path("_matrix/client/r0/user/@example:localhost/account_data/m.direct"))
.and(header("authorization", "Bearer 1234"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!(["hey", null, true, 42])))
Copy link
Member

Choose a reason for hiding this comment

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

That's my new catchy phrase: hey null true 42!

@bnjbvr bnjbvr merged commit 10fd5d0 into main Jul 3, 2024
39 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/dont-clobber-dm-list branch July 3, 2024 10:00
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.

Element X can overwrite user's DM rooms
2 participants