forked from GitHub-Mirror/riotX-android
Merge branch 'develop' into feature/pending_edits_ux
This commit is contained in:
@ -41,6 +41,7 @@ interface PushRuleService {
|
||||
|
||||
interface PushRuleListener {
|
||||
fun onMatchRule(event: Event, actions: List<Action>)
|
||||
fun onRoomLeft(roomId: String)
|
||||
fun batchFinish()
|
||||
}
|
||||
}
|
@ -20,12 +20,10 @@ import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.auth.data.SessionParams
|
||||
import im.vector.matrix.android.api.pushrules.Action
|
||||
import im.vector.matrix.android.api.pushrules.PushRuleService
|
||||
import im.vector.matrix.android.api.pushrules.rest.GetPushRulesResponse
|
||||
import im.vector.matrix.android.api.pushrules.rest.PushRule
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.internal.database.mapper.PushRulesMapper
|
||||
import im.vector.matrix.android.internal.database.model.PushRulesEntity
|
||||
import im.vector.matrix.android.internal.database.model.PusherEntityFields
|
||||
import im.vector.matrix.android.internal.database.query.where
|
||||
import im.vector.matrix.android.internal.session.SessionScope
|
||||
import im.vector.matrix.android.internal.session.pushers.GetPushRulesTask
|
||||
@ -122,13 +120,23 @@ internal class DefaultPushRuleService @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun dispatchRoomLeft(roomid: String) {
|
||||
try {
|
||||
listeners.forEach {
|
||||
it.onRoomLeft(roomid)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Error while dispatching room left")
|
||||
}
|
||||
}
|
||||
|
||||
fun dispatchFinish() {
|
||||
try {
|
||||
listeners.forEach {
|
||||
it.batchFinish()
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
|
||||
Timber.e(e, "Error while dispatching finish")
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,10 @@ internal class DefaultProcessEventForPushTask @Inject constructor(
|
||||
|
||||
override suspend fun execute(params: ProcessEventForPushTask.Params): Try<Unit> {
|
||||
return Try {
|
||||
// Handle left rooms
|
||||
params.syncResponse.leave.keys.forEach {
|
||||
defaultPushRuleService.dispatchRoomLeft(it)
|
||||
}
|
||||
val newJoinEvents = params.syncResponse.join
|
||||
.map { entries ->
|
||||
entries.value.timeline?.events?.map { it.copy(roomId = entries.key) }
|
||||
|
Reference in New Issue
Block a user