mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
making the removePusher more generic as it can handle email and http pushers
- Updates the doc to reflect that to remove emails an appId of m.email is required
This commit is contained in:
parent
78d70eab12
commit
2c25efc36a
4 changed files with 7 additions and 16 deletions
|
@ -99,14 +99,10 @@ interface PushersService {
|
|||
eventId: String)
|
||||
|
||||
/**
|
||||
* Remove the http pusher
|
||||
* Remove the pusher
|
||||
* When the appId is m.email then an email address is expected in the pushkey
|
||||
*/
|
||||
suspend fun removeHttpPusher(pushkey: String, appId: String)
|
||||
|
||||
/**
|
||||
* Remove the email pusher for a given email
|
||||
*/
|
||||
suspend fun removeEmailPusher(email: String)
|
||||
suspend fun removePusher(pushkey: String, appId: String)
|
||||
|
||||
/**
|
||||
* Get the current pushers, as a LiveData
|
||||
|
|
|
@ -114,16 +114,11 @@ internal class DefaultPushersService @Inject constructor(
|
|||
this.data?.url?.let { url -> if ("/_matrix/push/v1/notify" !in url) throw InvalidParameterException("url should contain '/_matrix/push/v1/notify'") }
|
||||
}
|
||||
|
||||
override suspend fun removeHttpPusher(pushkey: String, appId: String) {
|
||||
override suspend fun removePusher(pushkey: String, appId: String) {
|
||||
val params = RemovePusherTask.Params(pushkey, appId)
|
||||
removePusherTask.execute(params)
|
||||
}
|
||||
|
||||
override suspend fun removeEmailPusher(email: String) {
|
||||
val params = RemovePusherTask.Params(email, "m.email")
|
||||
removePusherTask.execute(params)
|
||||
}
|
||||
|
||||
override fun getPushersLive(): LiveData<List<Pusher>> {
|
||||
return monarchy.findAllMappedWithChanges(
|
||||
{ realm -> PusherEntity.where(realm) },
|
||||
|
|
|
@ -75,12 +75,12 @@ class PushersManager @Inject constructor(
|
|||
|
||||
suspend fun unregisterEmailPusher(email: String) {
|
||||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
||||
currentSession.removeEmailPusher(email)
|
||||
currentSession.removePusher(email, appId = "m.email")
|
||||
}
|
||||
|
||||
suspend fun unregisterPusher(pushKey: String) {
|
||||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
||||
currentSession.removeHttpPusher(pushKey, stringProvider.getString(R.string.pusher_app_id))
|
||||
currentSession.removePusher(pushKey, stringProvider.getString(R.string.pusher_app_id))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -79,7 +79,7 @@ class PushGatewaysViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
|
||||
private fun removePusher(pusher: Pusher) {
|
||||
viewModelScope.launch {
|
||||
session.removeHttpPusher(pusher.pushKey, pusher.appId)
|
||||
session.removePusher(pusher.pushKey, pusher.appId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue