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

refactor(media): some preparatory refactorings #4140

Merged
merged 11 commits into from
Oct 17, 2024
Merged

refactor(media): some preparatory refactorings #4140

merged 11 commits into from
Oct 17, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Oct 16, 2024

aka "Benjamin tries to make sense of the media code. Oh, nice: it makes sense."

Part of #1732.

…ding the content

The tails of the prepare_attachment_message and
prepare_encrypted_attachment_message were almost the same, with the one
different that they were using different ctors for the `EventContent`
types. In fact, all these `EventContent` types also expose a plain `new`
function that can take in either an encrypted or a plain media source,
so we can commonize the code there.
@bnjbvr bnjbvr requested a review from a team as a code owner October 16, 2024 15:40
@bnjbvr bnjbvr requested review from poljar and removed request for a team October 16, 2024 15:40
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 51.68539% with 43 lines in your changes missing coverage. Please review.

Project coverage is 84.81%. Comparing base (30f3a3c) to head (b89e609).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/room/mod.rs 48.27% 30 Missing ⚠️
crates/matrix-sdk/src/encryption/mod.rs 7.14% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4140      +/-   ##
==========================================
+ Coverage   84.72%   84.81%   +0.09%     
==========================================
  Files         269      269              
  Lines       28779    28759      -20     
==========================================
+ Hits        24384    24393       +9     
+ Misses       4395     4366      -29     

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

Comment on lines 545 to 547
let mut content = ImageMessageEventContent::plain(body, url).info(Box::new(info));
content.filename = filename;
content.formatted = config.formatted_caption;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could also use the assign! macro here (I think I saw it still being used in a bunch of other places). Same for the other changes in this commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, make_attachment in the latest version does maximally use assign!, IMO 👍

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Nicely done.

…tion_id`

This allows letting the caller whether they need to clone it or not, and
avoids a spurious clone in one call site.
…caller

The name wasn't very descriptive, and it's tweaking the content, so
let's do that in place, instead of deferring to another method somewhere
else in the codebase.
…tedFile`

Changelog: Renamed `PrepareEncryptedFile` and
`Client::prepare_encrypted_file` to `UploadEncryptedFile` and
`Client::upload_encrypted_file`.
@bnjbvr bnjbvr enabled auto-merge (rebase) October 17, 2024 14:41
@bnjbvr bnjbvr merged commit 08152bd into main Oct 17, 2024
40 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/media branch October 17, 2024 14:54
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.

3 participants