Fix / ignore message sent by me in push rules

This commit is contained in:
Valere 2019-06-24 14:35:12 +02:00 committed by Benoit Marty
parent 7821ca12fd
commit 090ee1d4e9
2 changed files with 9 additions and 5 deletions

View file

@ -192,7 +192,7 @@ internal class SessionModule(private val sessionParams: SessionParams) {
}
scope(DefaultSession.SCOPE) {
BingRuleWatcher(get(), get(), get(), get())
BingRuleWatcher(get(), get(), get(), get(), get())
}
scope(DefaultSession.SCOPE) {

View file

@ -16,6 +16,7 @@
package im.vector.matrix.android.internal.session.notification
import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.api.auth.data.SessionParams
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.internal.database.RealmLiveEntityObserver
import im.vector.matrix.android.internal.database.mapper.asDomain
@ -28,6 +29,7 @@ import im.vector.matrix.android.internal.task.configureWith
internal class BingRuleWatcher(monarchy: Monarchy,
private val task: ProcessEventForPushTask,
private val defaultPushRuleService: DefaultPushRuleService,
private val sessionParams: SessionParams,
private val taskExecutor: TaskExecutor) :
RealmLiveEntityObserver<EventEntity>(monarchy) {
@ -41,10 +43,12 @@ internal class BingRuleWatcher(monarchy: Monarchy,
override fun processChanges(inserted: List<EventEntity>, updated: List<EventEntity>, deleted: List<EventEntity>) {
val rules = defaultPushRuleService.getPushrules("global")
inserted.map { it.asDomain() }.let { events ->
task.configureWith(ProcessEventForPushTask.Params(events, rules))
.executeBy(taskExecutor)
}
inserted.map { it.asDomain() }
.filter { it.senderId != sessionParams.credentials.userId }
.let { events ->
task.configureWith(ProcessEventForPushTask.Params(events, rules))
.executeBy(taskExecutor)
}
}