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(ffi): remove duplicated fields in media event contents #4250

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Nov 12, 2024

The caption and filenames were weirdly duplicated in each media content, when the expected behavior is well defined:

  • if there's both a caption and a filename, body := caption, filename is its own field.
  • if there's only a filename, body := filename.

We can remove all duplicated fields, knowing this, and reconstruct the body based on that information. This should make it clearer to FFI users which is what, and provide a clearer API when creating the caption and so on.

@bnjbvr bnjbvr requested a review from a team as a code owner November 12, 2024 14:03
@bnjbvr bnjbvr requested review from andybalaam and removed request for a team November 12, 2024 14:03
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.94%. Comparing base (d446eb9) to head (ae006dc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4250      +/-   ##
==========================================
+ Coverage   84.91%   84.94%   +0.03%     
==========================================
  Files         274      274              
  Lines       29768    29768              
==========================================
+ Hits        25278    25287       +9     
+ Misses       4490     4481       -9     

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

@@ -262,6 +262,23 @@ pub enum MessageType {
Other { msgtype: String, body: String },
}

/// From MSC2530: https://github.com/tulir/matrix-spec-proposals/blob/body-as-caption/proposals/2530-body-as-caption.md
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! was copied from a place which used it, so I updated both :)

The caption and filenames were weirdly duplicated in each media content,
when the expected behavior is well defined:

- if there's both a caption and a filename, body := caption, filename is
its own field.
- if there's only a filename, body := filename.

We can remove all duplicated fields, knowing this, and reconstruct the
body based on that information. This should make it clearer to FFI users
which is what, and provide a clearer API when creating the caption and
so on.
@bnjbvr bnjbvr force-pushed the bnjbvr/ffi-refactor-media-event-content branch from 77ebb88 to ae006dc Compare November 12, 2024 15:06
@bnjbvr bnjbvr enabled auto-merge (rebase) November 12, 2024 15:07
@bnjbvr bnjbvr merged commit f341dc4 into main Nov 12, 2024
40 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/ffi-refactor-media-event-content branch November 12, 2024 15:22
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.

2 participants