From 516bb6ed951005a991671920feea7fd1e3ed4a73 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 21 Sep 2021 11:26:11 +0100 Subject: [PATCH] lifting the email branding to its own parameter so clients of the sdk can configure it --- .../android/sdk/api/session/pushers/PushersService.kt | 2 ++ .../sdk/internal/session/pushers/DefaultPushersService.kt | 7 ++++--- .../main/java/im/vector/app/core/pushers/PushersManager.kt | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt index 2766147cc9..fc080a0985 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt @@ -70,6 +70,7 @@ interface PushersService { * @param email The email address to send notifications to. * If the kind is "email", this is the email address to send notifications to. * @param lang The preferred language for receiving notifications (e.g. "en" or "en-US"). + * @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. * @param append If true, the homeserver should add another pusher with the given pushkey and App ID in addition @@ -81,6 +82,7 @@ interface PushersService { */ fun addEmailPusher(email: String, lang: String, + emailBranding: String, appDisplayName: String, deviceDisplayName: String, append: Boolean): UUID diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt index a7fd3d435f..61e875b8e5 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt @@ -81,15 +81,16 @@ internal class DefaultPushersService @Inject constructor( ) ) - override fun addEmailPusher(email: String, lang: String, appDisplayName: String, deviceDisplayName: String, append: Boolean) = addPusher( - JsonPusher(pushKey = email, + override fun addEmailPusher(email: String, lang: String, emailBranding: String, appDisplayName: String, deviceDisplayName: String, append: Boolean) = addPusher( + JsonPusher( + pushKey = email, kind = "email", appId = "m.email", profileTag = "", lang = lang, appDisplayName = appDisplayName, deviceDisplayName = deviceDisplayName, - data = JsonPusherData(brand = appDisplayName), + data = JsonPusherData(brand = emailBranding), append = append ) ) diff --git a/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt b/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt index fa39823c36..03f82d3fc9 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/PushersManager.kt @@ -63,10 +63,12 @@ class PushersManager @Inject constructor( fun registerEmailForPush(email: String) { val currentSession = activeSessionHolder.getActiveSession() + val appName = appNameProvider.getAppName() currentSession.addEmailPusher( email = email, lang = localeProvider.current().language, - appDisplayName = appNameProvider.getAppName(), + emailBranding = appName, + appDisplayName = appName, deviceDisplayName = currentSession.sessionParams.deviceId ?: "MOBILE", append = true, )