extracting constants for the pusher kinds and email appId

This commit is contained in:
Adam Brown 2021-09-23 12:33:48 +01:00
parent 4c4f2fce74
commit d31ad7e187
3 changed files with 15 additions and 8 deletions

View file

@ -26,7 +26,15 @@ data class Pusher(
val data: PusherData,
val state: PusherState
)
) {
companion object {
const val KIND_EMAIL = "email"
const val KIND_HTTP = "http"
const val APP_ID_EMAIL = "m.email"
}
}
enum class PusherState {
UNREGISTERED,

View file

@ -70,7 +70,7 @@ internal class DefaultPushersService @Inject constructor(
) = addPusher(
JsonPusher(
pushKey = pushkey,
kind = "http",
kind = Pusher.KIND_HTTP,
appId = appId,
profileTag = profileTag,
lang = lang,
@ -84,8 +84,8 @@ internal class DefaultPushersService @Inject constructor(
override fun addEmailPusher(email: String, lang: String, emailBranding: String, appDisplayName: String, deviceDisplayName: String) = addPusher(
JsonPusher(
pushKey = email,
kind = "email",
appId = "m.email",
kind = Pusher.KIND_EMAIL,
appId = Pusher.APP_ID_EMAIL,
profileTag = "",
lang = lang,
appDisplayName = appDisplayName,

View file

@ -37,10 +37,9 @@ abstract class PushGatewayItem : EpoxyModelWithHolder<PushGatewayItem.Holder>()
override fun bind(holder: Holder) {
super.bind(holder)
holder.kind.text = when (pusher.kind) {
// TODO Create const
"http" -> "Http Pusher"
"mail" -> "Email Pusher"
else -> pusher.kind
Pusher.KIND_HTTP -> "Http Pusher"
Pusher.KIND_EMAIL -> "Email Pusher"
else -> pusher.kind
}
holder.appId.text = pusher.appId