-
Notifications
You must be signed in to change notification settings - Fork 754
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
Add email notification toggle #4052
Conversation
- email pushes make use of a new undocumented `brand` field, for now this field maps directly to the app display name so we can resuse it
- will display a _no emails_ when the matrix account has no emails set and tapping will navigate to the emails and phone numbers screen where the user can add an email - toggling the email notification with register and unregister push notification for the given email address
- Extracts out a transactional switch helper to handle reverting the switch back to its original state if an error occurs - Reuses existing toast message for unknown error - Does not include the isAdded to the async callback as the couroutine is tied to the fragment lifecycle scope
… can configure it
- always appending allows the same email to be used for other accounts see matrix-org/matrix-react-sdk#2727 https://github.com/matrix-org/matrix-react-sdk/pull/2727/files#diff-ec232520bf51337e5e6939b885d21f428ad6da3306c8e17a3ff660b2b341179dR165
…pushers - Updates the doc to reflect that to remove emails an appId of m.email is required
…self closing tag - the category is dynamically populated so we shouldn't be adding anything static here anyways!
…ch rather than when the listener is initially set
...m/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt
Outdated
Show resolved
Hide resolved
append = append) | ||
withEventIdOnly: Boolean | ||
) = addPusher( | ||
JsonPusher( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a lot of duplication here caused by the amount of parameters, the next PR coming up will address this by introducing a dedicated HttpPusher
data class
*/ | ||
suspend fun removeHttpPusher(pushkey: String, appId: String) | ||
suspend fun removePusher(pushkey: String, appId: String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed because technically this function can remove email and http pushers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks, but maybe for clarity / symmetry keep removeHttpPusher
and add new fun removeEmailPusher
which takes only one parameter email
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had that but it felt odd that PushGateway
could still use the removeHttpPusher
for both http and email pushers
the PushersManager
has symmetrical register/unregister for http and email but that's a layer above the SDK
we could force the different flows based on appId
fun removePusher(pusher: Pusher) {
when (pusher.appId) {
Pusher.APP_ID_EMAIL -> session.removeEmailPusher(pusher.pushKey)
else -> session.removeHttpPusher(pusher.pushKey, pusher.appId)
}
}
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PushersManager
is on the app side, so I would say its Api is less "important" than the SDK API PushersService
. I agree that removeHttpPusher
is not KO to remove email pushers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after speaking offline, I've opted for adding a 3rd method for removing Pushers
4482cbd this has the benefit of avoiding redundancy in checking the appId if we already have a pusher
instance and we can have dedicated symmetrical http/email removal functions for convenience
* @param emailBranding The branding placeholder to include in the email communications. | ||
* @param appDisplayName A human readable string that will allow the user to identify what application owns this pusher. | ||
* @param deviceDisplayName A human readable string that will allow the user to identify what device owns this pusher. | ||
* @return A work request uuid. Can be used to listen to the status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the next PR will remove the reliance on the WorkManager
by switching to a suspend fun
, allowing us to handle and simplify the registration errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work thanks.
A few comments and remarks
*/ | ||
suspend fun removeHttpPusher(pushkey: String, appId: String) | ||
suspend fun removePusher(pushkey: String, appId: String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks, but maybe for clarity / symmetry keep removeHttpPusher
and add new fun removeEmailPusher
which takes only one parameter email
?
...droid/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt
Outdated
Show resolved
Hide resolved
...droid/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt
Outdated
Show resolved
Hide resolved
|
||
val params = AddHttpPusherWorker.Params(sessionId, pusher) | ||
override fun addEmailPusher(email: String, lang: String, emailBranding: String, appDisplayName: String, deviceDisplayName: String) = addPusher( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One param per line is better when there are a lot of parameters like here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why there is no param append
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
append
was removed as an option because it sounds like it has the side effect of causing other accounts which use the same email to lose email notifications https://github.com/matrix-org/matrix-react-sdk/pull/2727/files#diff-ec232520bf51337e5e6939b885d21f428ad6da3306c8e17a3ff660b2b341179dR165
happy to add back if you think it should be configurable by clients
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's sometimes difficult to decide between what we want the SDK to expose (as parameters for instance) and what we want the SDK to handle, so keep hidden from the client app. On one side the SDK should let the app do whatever it wants to, and on the other side we want the SDK to provide a high level service... So maybe add the parameter, with default value to true
and with the same comment from https://github.com/matrix-org/matrix-react-sdk/pull/2727/files#diff-ec232520bf51337e5e6939b885d21f428ad6da3306c8e17a3ff660b2b341179dR165 in the doc of the fun addEmailPusher
.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, will do 👍
...m/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt
Show resolved
Hide resolved
...m/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt
Outdated
Show resolved
Hide resolved
vector/src/main/java/im/vector/app/features/settings/push/PushGatewaysViewModel.kt
Outdated
Show resolved
Hide resolved
5033ea5
to
8316728
Compare
… it's not directly tied to the class
- displays a dialog with a human readable version of the error
… is the case for email pushers)
…n returning from adding an email - makes use of both sync and async fetching so that the page can avoid jumping around on the initial load
8cfdc43
to
3a1cb1c
Compare
vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt
Outdated
Show resolved
Hide resolved
… typically we wouldn't want to overwrite other accounts but we can expose the option to clients if they want that behaviour
…hers - also adds a separate removePusher which supports removing any type of pusher
@@ -75,12 +75,12 @@ class PushersManager @Inject constructor( | |||
|
|||
suspend fun unregisterEmailPusher(email: String) { | |||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return | |||
currentSession.removePusher(email, appId = "m.email") | |||
currentSession.removeEmailPusher(email) | |||
} | |||
|
|||
suspend fun unregisterPusher(pushKey: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: rename to unregisterHttpPusher
for parity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, LGTM!
#2243 Email notification toggles
Email notifications
category tosettings/notifications
which allows for individually toggling email notifications for all associated emailsEmail and Phone numbers
screenaddEmailPusher
functionality is added to thematrix-sdk PushersService
which allows an email address to be registered or unregistered for notificationsREMOVE
button to thesettings/advanced settings/notification targets
AddHttpPusher
classes toAddPusher
as they were able to be repurposed for emails