using dedicated pusher removal methods for the different types of pushers
- also adds a separate removePusher which supports removing any type of pusher
This commit is contained in:
parent
7fd794bd7a
commit
4482cbdaa6
@ -102,10 +102,22 @@ interface PushersService {
|
|||||||
eventId: String)
|
eventId: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the pusher
|
* Remove a registered pusher
|
||||||
* When the appId is m.email then an email address is expected in the pushkey
|
* @param pusher the pusher to remove, can be http or email
|
||||||
*/
|
*/
|
||||||
suspend fun removePusher(pushkey: String, appId: String)
|
suspend fun removePusher(pusher: Pusher)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a Http pusher by its pushkey and appId
|
||||||
|
* @see addHttpPusher
|
||||||
|
*/
|
||||||
|
suspend fun removeHttpPusher(pushkey: String, appId: String)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an Email pusher
|
||||||
|
* @see addEmailPusher
|
||||||
|
*/
|
||||||
|
suspend fun removeEmailPusher(email: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current pushers, as a LiveData
|
* Get the current pushers, as a LiveData
|
||||||
|
@ -120,8 +120,20 @@ internal class DefaultPushersService @Inject constructor(
|
|||||||
data?.url?.let { url -> if ("/_matrix/push/v1/notify" !in url) throw InvalidParameterException("url should contain '/_matrix/push/v1/notify'") }
|
data?.url?.let { url -> if ("/_matrix/push/v1/notify" !in url) throw InvalidParameterException("url should contain '/_matrix/push/v1/notify'") }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun removePusher(pushkey: String, appId: String) {
|
override suspend fun removePusher(pusher: Pusher) {
|
||||||
val params = RemovePusherTask.Params(pushkey, appId)
|
removePusher(pusher.pushKey, pusher.appId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun removeHttpPusher(pushkey: String, appId: String) {
|
||||||
|
removePusher(pushkey, appId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun removeEmailPusher(email: String) {
|
||||||
|
removePusher(pushKey = email, Pusher.APP_ID_EMAIL)
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun removePusher(pushKey: String, pushAppId: String) {
|
||||||
|
val params = RemovePusherTask.Params(pushKey, pushAppId)
|
||||||
removePusherTask.execute(params)
|
removePusherTask.execute(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,12 +75,12 @@ class PushersManager @Inject constructor(
|
|||||||
|
|
||||||
suspend fun unregisterEmailPusher(email: String) {
|
suspend fun unregisterEmailPusher(email: String) {
|
||||||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
currentSession.removePusher(email, appId = "m.email")
|
currentSession.removeEmailPusher(email)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun unregisterPusher(pushKey: String) {
|
suspend fun unregisterPusher(pushKey: String) {
|
||||||
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
val currentSession = activeSessionHolder.getSafeActiveSession() ?: return
|
||||||
currentSession.removePusher(pushKey, stringProvider.getString(R.string.pusher_app_id))
|
currentSession.removeHttpPusher(pushKey, stringProvider.getString(R.string.pusher_app_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -79,7 +79,7 @@ class PushGatewaysViewModel @AssistedInject constructor(@Assisted initialState:
|
|||||||
private fun removePusher(pusher: Pusher) {
|
private fun removePusher(pusher: Pusher) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
session.removePusher(pusher.pushKey, pusher.appId)
|
session.removePusher(pusher)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
_viewEvents.post(PushGatewayViewEvents.RemovePusherFailed(it))
|
_viewEvents.post(PushGatewayViewEvents.RemovePusherFailed(it))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user