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

FFI Element Call: Fix the permission list returned by the get_element_call_required_permissions ffi function. #3814

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

toger5
Copy link
Contributor

@toger5 toger5 commented Aug 7, 2024

Before we set them for reading events which is not required since:

read: vec![
  WidgetEventFilter::StateWithType { event_type: StateEventType::CallMember.to_string() },
]

already covers all keys. And an additional @ was used resulting in:
@@user_id:demain.org_DEVICEID and _@@user_id:demain.org_DEVICEID.

This also made it obvious that we need unit tests for this ffi method!

(We currently use the tauri widget wrapper to do manual end to end tests for the widget driver. But the ffi layer is not part of the tauri app. The testing cycle for EX is cumbersome without merging the changes.
Offtopic: any ideas or recommendations how to mitigate this in the future are welcome)

  • Public API changes documented in changelogs (optional)

Signed-off-by:

@toger5 toger5 marked this pull request as ready for review August 7, 2024 16:43
@toger5 toger5 requested a review from a team as a code owner August 7, 2024 16:43
@toger5 toger5 requested review from richvdh and removed request for a team August 7, 2024 16:43
@toger5 toger5 force-pushed the toger5/fix-get_element_call_required_permissions-ffi branch from 01dd246 to c6a7405 Compare August 7, 2024 16:47
Copy link

codecov bot commented Aug 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.09%. Comparing base (71b5ab4) to head (793a67a).
Report is 41 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3814      +/-   ##
==========================================
+ Coverage   84.08%   84.09%   +0.01%     
==========================================
  Files         262      262              
  Lines       27434    27434              
==========================================
+ Hits        23067    23070       +3     
+ Misses       4367     4364       -3     

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

WidgetEventFilter::StateWithTypeAndStateKey {
event_type: StateEventType::CallMember.to_string(),
state_key: own_user_id,
state_key: format!("{}_{}", own_user_id, own_device_id),
Copy link
Member

Choose a reason for hiding this comment

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

Could be:

Suggested change
state_key: format!("{}_{}", own_user_id, own_device_id),
state_key: format!("{own_user_id}_{own_device_id}"),

Probably more Rust idiomatic.

// but we use mxId+deviceId.
WidgetEventFilter::StateWithTypeAndStateKey {
event_type: StateEventType::CallMember.to_string(),
state_key: format!("_{}_{}", own_user_id, own_device_id),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
state_key: format!("_{}_{}", own_user_id, own_device_id),
state_key: format!("_{own_user_id}_{own_device_id}"),

@@ -535,3 +540,54 @@ impl From<url::ParseError> for ParseError {
}
}
}

#[cfg(test)]
mod tests {
Copy link
Member

Choose a reason for hiding this comment

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

Tests from matrix-sdk-ffi aren't run in the CI as far as I remember. Is it possible to move some of this logic inside matrix-sdk maybe? I understand though that the code you're testing are specific to Element, and should not leave in matrix-sdk itself 🤔.

We may want to run the tests from matrix-sdk-ffi inside the CI then.

Can you open an issue, or better, a pull request, to not forget about that please?

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.

@toger5 is on holidays. I'm taking over this PR.

@Hywan Hywan merged commit 70f46d4 into main Aug 8, 2024
40 checks passed
@Hywan Hywan deleted the toger5/fix-get_element_call_required_permissions-ffi branch August 8, 2024 15: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.

2 participants