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:
Adam Brown 2021-09-21 12:06:26 +01:00
parent 78d70eab12
commit 2c25efc36a
4 changed files with 7 additions and 16 deletions

View File

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

View File

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

View File

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

View File

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