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

Silent unexpected notifications #1114

Closed
Tracked by #1794
manuroe opened this issue Jun 20, 2023 · 3 comments
Closed
Tracked by #1794

Silent unexpected notifications #1114

manuroe opened this issue Jun 20, 2023 · 3 comments
Assignees

Comments

@manuroe
Copy link
Member

manuroe commented Jun 20, 2023

We already have the com.apple.developer.usernotifications.filtering entitlement. We now need to use it to silent unexpected notifications following (Apple doc).

@Velin92
Copy link
Member

Velin92 commented Jun 21, 2023

  • First we should actually define what happens in case the get_notification_item function fails to fetch the notification (this means that an error occurred when trying to fetch the notification, like a filed request, or a failed db access) for now we are also displaying the generic notification for the error case.

  • Second we should check if there is any event type that we want notifications to be ALWAYS filtered out regardless of push rules.
    In fact if an event that is not a room message or an invite state event is currently received by the app, we just display a generic notification with the localised content:

These are all the types that the SDK may return (of course not all of them are going to trigger a push notification), I am adding a //handled comment nearby all the ones we handle with a specific notification.
For the other types in case a notification would arrive with such type we are displaying the generic notification.

In case for some of these we instead want to do a filter instead of displaying the generic we should annotate that.
The list is pretty extensive and most of them as I said probably will not even trigger a push, so we should just annotate what we plan to show as generic (or which ones we plan to handle properly in the future), while we can filter out completely all the others.
The code snippet comes from here: https://github.com/ruma/ruma/blob/main/crates/ruma-common/src/events/enums.rs

Events from the SDK

event_enum! {
    /// Any global account data event.
    enum GlobalAccountData {
        "m.direct" => super::direct,
        "m.identity_server" => super::identity_server,
        "m.ignored_user_list" => super::ignored_user_list,
        "m.push_rules" => super::push_rules,
        "m.secret_storage.default_key" => super::secret_storage::default_key,
        "m.secret_storage.key.*" => super::secret_storage::key,
    }

    /// Any room account data event.
    enum RoomAccountData {
        "m.fully_read" => super::fully_read,
        "m.tag" => super::tag,
    }

    /// Any ephemeral room event.
    enum EphemeralRoom {
        "m.receipt" => super::receipt,
        "m.typing" => super::typing,
    }

    /// Any message-like event.
    enum MessageLike {
        #[cfg(feature = "unstable-msc3927")]
        #[ruma_enum(alias = "m.audio")]
        "org.matrix.msc1767.audio" => super::audio,
        "m.call.answer" => super::call::answer,
        "m.call.invite" => super::call::invite,
        "m.call.hangup" => super::call::hangup,
        "m.call.candidates" => super::call::candidates,
        "m.call.negotiate" => super::call::negotiate,
        "m.call.reject" => super::call::reject,
        "m.call.select_answer" => super::call::select_answer,
        #[cfg(feature = "unstable-msc3954")]
        #[ruma_enum(alias = "m.emote")]
        "org.matrix.msc1767.emote" => super::emote,
        #[cfg(feature = "unstable-msc3956")]
        #[ruma_enum(alias = "m.encrypted")]
        "org.matrix.msc1767.encrypted" => super::encrypted,
        #[cfg(feature = "unstable-msc3551")]
        #[ruma_enum(alias = "m.file")]
        "org.matrix.msc1767.file" => super::file,
        #[cfg(feature = "unstable-msc3552")]
        #[ruma_enum(alias = "m.image")]
        "org.matrix.msc1767.image" => super::image,
        "m.key.verification.ready" => super::key::verification::ready,
        "m.key.verification.start" => super::key::verification::start,
        "m.key.verification.cancel" => super::key::verification::cancel,
        "m.key.verification.accept" => super::key::verification::accept,
        "m.key.verification.key" => super::key::verification::key,
        "m.key.verification.mac" => super::key::verification::mac,
        "m.key.verification.done" => super::key::verification::done,
        #[cfg(feature = "unstable-msc3488")]
        "m.location" => super::location,
        #[cfg(feature = "unstable-msc1767")]
        #[ruma_enum(alias = "m.message")]
        "org.matrix.msc1767.message" => super::message,
        #[cfg(feature = "unstable-msc3381")]
        #[ruma_enum(alias = "m.poll.start")]
        "org.matrix.msc3381.v2.poll.start" => super::poll::start,
        #[cfg(feature = "unstable-msc3381")]
        #[ruma_enum(alias = "m.poll.response")]
        "org.matrix.msc3381.v2.poll.response" => super::poll::response,
        #[cfg(feature = "unstable-msc3381")]
        #[ruma_enum(alias = "m.poll.end")]
        "org.matrix.msc3381.v2.poll.end" => super::poll::end,
        "m.reaction" => super::reaction,
        "m.room.encrypted" => super::room::encrypted, // handled always with a generic
        "m.room.message" => super::room::message, // handled for all the existing message types except location which for now we are displaying a generic one
        "m.room.redaction" => super::room::redaction,
        "m.sticker" => super::sticker,
        #[cfg(feature = "unstable-msc3553")]
        #[ruma_enum(alias = "m.video")]
        "org.matrix.msc1767.video" => super::video,
        #[cfg(feature = "unstable-msc3245")]
        #[ruma_enum(alias = "m.voice")]
        "org.matrix.msc3245.voice.v2" => super::voice,
    }

    /// Any state event.
    enum State {
        "m.policy.rule.room" => super::policy::rule::room,
        "m.policy.rule.server" => super::policy::rule::server,
        "m.policy.rule.user" => super::policy::rule::user,
        "m.room.aliases" => super::room::aliases,
        "m.room.avatar" => super::room::avatar,
        "m.room.canonical_alias" => super::room::canonical_alias,
        "m.room.create" => super::room::create,
        "m.room.encryption" => super::room::encryption,
        "m.room.guest_access" => super::room::guest_access,
        "m.room.history_visibility" => super::room::history_visibility,
        "m.room.join_rules" => super::room::join_rules,
        "m.room.member" => super::room::member, // handled for the invite case only otherwise generic
        "m.room.name" => super::room::name,
        "m.room.pinned_events" => super::room::pinned_events,
        "m.room.power_levels" => super::room::power_levels,
        "m.room.server_acl" => super::room::server_acl,
        "m.room.third_party_invite" => super::room::third_party_invite,
        "m.room.tombstone" => super::room::tombstone,
        "m.room.topic" => super::room::topic,
        "m.space.child" => super::space::child,
        "m.space.parent" => super::space::parent,
    }

    /// Any to-device event.
    enum ToDevice {
        "m.dummy" => super::dummy,
        "m.room_key" => super::room_key,
        "m.room_key_request" => super::room_key_request,
        "m.forwarded_room_key" => super::forwarded_room_key,
        "m.key.verification.request" => super::key::verification::request,
        "m.key.verification.ready" => super::key::verification::ready,
        "m.key.verification.start" => super::key::verification::start,
        "m.key.verification.cancel" => super::key::verification::cancel,
        "m.key.verification.accept" => super::key::verification::accept,
        "m.key.verification.key" => super::key::verification::key,
        "m.key.verification.mac" => super::key::verification::mac,
        "m.key.verification.done" => super::key::verification::done,
        "m.room.encrypted" => super::room::encrypted,
        "m.secret.request"=> super::secret::request,
        "m.secret.send" => super::secret::send,
    }
}
  • Then for filtering out based on push rules we probably can have the notification from the rust side iterate over the push rules and decide to return the notification item or not (the ruma_common provides a push rules iterator, however a way to verify that the event conforms to the rule needs to be implemented).

By the way this is the generic notification:
Element X
Notification

@manuroe
Copy link
Member Author

manuroe commented Jun 21, 2023

Summary of chat discussions:

  • the app must rely only on push rules for filtering
  • edge cases have been better defined in the acceptance criteria of the user story

@Velin92
Copy link
Member

Velin92 commented Jun 27, 2023

This is technically already in the app but has been disabled for now until we fix this issue described here:
#1155

Will open an issue on the Matrix Rust SDK

@Velin92 Velin92 closed this as completed Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants