From 090ee1d4e927be6a3bc85798499b343398cf1ea0 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 24 Jun 2019 14:35:12 +0200 Subject: [PATCH] Fix / ignore message sent by me in push rules --- .../matrix/android/internal/session/SessionModule.kt | 2 +- .../internal/session/notification/BingRuleWatcher.kt | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionModule.kt index b517fade9a..a3a08976e1 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionModule.kt @@ -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) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/BingRuleWatcher.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/BingRuleWatcher.kt index af5689cf5f..b584fd8e5d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/BingRuleWatcher.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/BingRuleWatcher.kt @@ -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(monarchy) { @@ -41,10 +43,12 @@ internal class BingRuleWatcher(monarchy: Monarchy, override fun processChanges(inserted: List, updated: List, deleted: List) { 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) + } }