lifting the email branding to its own parameter so clients of the sdk can configure it

This commit is contained in:
Adam Brown 2021-09-21 11:26:11 +01:00
parent 0b293d08cc
commit 516bb6ed95
3 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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
)
)

View File

@ -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,
)