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

feat(room): Add fn Room::own_membership_details #4529

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

jmartinesp
Copy link
Contributor

@jmartinesp jmartinesp commented Jan 14, 2025

This will retrieve the room member info of both the current user and the info for the sender of the current user's room member event and make it accessible in the FFI layer.

This is needed for RoomPreview to display messages such as 'you were banned from this room by Foo'.

  • Public API changes documented in changelogs (optional)

Signed-off-by:

@jmartinesp jmartinesp requested a review from a team as a code owner January 14, 2025 11:49
@jmartinesp jmartinesp requested review from poljar and removed request for a team January 14, 2025 11:49
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.

Looks sensible, a test for the method would be nice.

/// current user's [`RoomMember`](RoomMember) info and the member info
/// of the sender of that member event.
/// - If the current user is not present, an error.
pub async fn own_membership_details(&self) -> Result<(RoomMember, Option<RoomMember>)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get a simple smoke test for this method, I know it's a pretty simple method but it would still be nice to test its basic functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a few tests and force pushed. Thanks for the reminder, that uncovered a subtle bug!

This will retrieve the room member info of both the current user and the info for the sender of the current user's room member event.
Also add `membership_change_reason` field to `ffi::RoomMember`.
@jmartinesp jmartinesp force-pushed the feat/room-own-membership-details branch from 15f8457 to c0f7ff0 Compare January 14, 2025 15:00
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.45%. Comparing base (b9014a5) to head (c0f7ff0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/room/mod.rs 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4529      +/-   ##
==========================================
+ Coverage   85.43%   85.45%   +0.02%     
==========================================
  Files         285      285              
  Lines       32101    32112      +11     
==========================================
+ Hits        27426    27442      +16     
+ Misses       4675     4670       -5     

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

@jmartinesp jmartinesp merged commit bd5d7aa into main Jan 14, 2025
40 checks passed
@jmartinesp jmartinesp deleted the feat/room-own-membership-details branch January 14, 2025 15:23
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