Skip to content

feat: add a new NotificationClient API 📬 #2235

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

Merged
merged 17 commits into from
Jul 10, 2023

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jul 6, 2023

This is extracted from #2204, and this implements a proper NotificationClient, that will take care of handling event decryption for notification events. It's also more logical to have something like this in the UI crate, instead of having custom code at the FFI layer.

For now, the FFI code has been moved, and the encryption sync usage for the notification decryption has been included there. In the future, I'm planning to add more, like properly handling invites, and more goodness to address #2179.

I'd like to include tests too, but might be nice to do as a follow-up to not inflate this PR too much.

Fixes #1962.

@bnjbvr bnjbvr requested a review from a team as a code owner July 6, 2023 15:00
@bnjbvr bnjbvr requested review from jplatte and removed request for a team July 6, 2023 15:00
///
/// In particular, it takes care of running a full decryption sync, in case the
/// event in the notification was impossible to decrypt beforehands.
pub struct NotificationClient {
Copy link
Member

Choose a reason for hiding this comment

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

Since we are in matrix_sdk_ui, I think it makes sense to rename the type to simply Notification. We don't have SlidingSyncClient nor RoomListClient after all :-).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like it, we'd be using the same type name for different things in different places.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have preferences for the names? The obvious ideas don't sound really good to my ears either: NotificationHandler, NotificationResolver, NotificationService (despite me not loving the Service suffix, there's an argument to be made that App could be SyncService and that would make for a nice parallel).

Maybe NotificationResolver isn't the worst?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the Client suffix is fine, it's a Matrix client the notification process should use. As such NotificationClient or NotificationServiceClient sounds fine to me.

Agree with @jplatte that Notification is too ambiguous and already used.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, let's keep NotificationClient for that one then!

@codecov
Copy link

codecov bot commented Jul 6, 2023

Codecov Report

Patch coverage: 48.11% and project coverage change: -0.17 ⚠️

Comparison is base (a094e10) 76.87% compared to head (274d1ab) 76.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2235      +/-   ##
==========================================
- Coverage   76.87%   76.71%   -0.17%     
==========================================
  Files         170      171       +1     
  Lines       17944    18027      +83     
==========================================
+ Hits        13795    13829      +34     
- Misses       4149     4198      +49     
Impacted Files Coverage Δ
crates/matrix-sdk-ui/src/lib.rs 100.00% <ø> (ø)
crates/matrix-sdk-ui/src/encryption_sync/mod.rs 56.57% <45.65%> (-9.46%) ⬇️
crates/matrix-sdk-ui/src/notification_client.rs 50.00% <50.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bnjbvr bnjbvr force-pushed the notification-client-api branch from e8070df to 20a4749 Compare July 7, 2023 11:07
@bnjbvr bnjbvr mentioned this pull request Jul 7, 2023
@bnjbvr
Copy link
Member Author

bnjbvr commented Jul 10, 2023

This was tested and approved by the iOS folks over at #2204, which stacks on top of this PR.

///
/// In particular, it takes care of running a full decryption sync, in case the
/// event in the notification was impossible to decrypt beforehands.
pub struct NotificationClient {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like it, we'd be using the same type name for different things in different places.

@bnjbvr bnjbvr requested a review from jplatte July 10, 2023 15:00
@bnjbvr bnjbvr merged commit 2acc13e into matrix-org:main Jul 10, 2023
@bnjbvr bnjbvr deleted the notification-client-api branch July 10, 2023 16:06
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.

Create a "Notification service" specific client which supports only a subset of the whole sync logic
4 participants