From 9119cf059f943ba7d85abd0c52c6d751c8e1a370 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 31 Jan 2022 12:06:21 +0000 Subject: [PATCH] adding extra logging around the push rules to help determine if we're incorrectly filter out valid notifications --- .../session/notification/ProcessEventForPushTask.kt | 1 + .../notifications/NotifiableEventProcessor.kt | 11 ++++++++--- .../features/notifications/PushRuleTriggerListener.kt | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt index da15e158e5..8b05d2ea62 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt @@ -74,6 +74,7 @@ internal class DefaultProcessEventForPushTask @Inject constructor( event to it } } + Timber.d("[PushRules] matched ${matchedEvents.size} out of ${allEvents.size}") val allRedactedEvents = params.syncResponse.join .asSequence() diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventProcessor.kt b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventProcessor.kt index 3d10d74fe3..351f085b7e 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventProcessor.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventProcessor.kt @@ -20,6 +20,7 @@ import im.vector.app.features.invite.AutoAcceptInvites import im.vector.app.features.notifications.ProcessedEvent.Type.KEEP import im.vector.app.features.notifications.ProcessedEvent.Type.REMOVE import org.matrix.android.sdk.api.session.events.model.EventType +import timber.log.Timber import javax.inject.Inject private typealias ProcessedEvents = List> @@ -33,9 +34,13 @@ class NotifiableEventProcessor @Inject constructor( val processedEvents = queuedEvents.map { val type = when (it) { is InviteNotifiableEvent -> if (autoAcceptInvites.hideInvites) REMOVE else KEEP - is NotifiableMessageEvent -> if (shouldIgnoreMessageEventInRoom(currentRoomId, it.roomId) || outdatedDetector.isMessageOutdated(it)) { - REMOVE - } else KEEP + is NotifiableMessageEvent -> when { + shouldIgnoreMessageEventInRoom(currentRoomId, it.roomId) -> REMOVE + .also { Timber.d("notification message removed due to currently viewing the same room") } + outdatedDetector.isMessageOutdated(it) -> REMOVE + .also { Timber.d("notification message removed due to being read") } + else -> KEEP + } is SimpleNotifiableEvent -> when (it.type) { EventType.REDACTION -> REMOVE else -> KEEP diff --git a/vector/src/main/java/im/vector/app/features/notifications/PushRuleTriggerListener.kt b/vector/src/main/java/im/vector/app/features/notifications/PushRuleTriggerListener.kt index ff817520db..cd08820fc1 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/PushRuleTriggerListener.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/PushRuleTriggerListener.kt @@ -55,12 +55,12 @@ class PushRuleTriggerListener @Inject constructor( private suspend fun createNotifiableEvents(pushEvents: PushEvents, session: Session): List { return pushEvents.matchedEvents.mapNotNull { (event, pushRule) -> - Timber.v("Push rule match for event ${event.eventId}") + Timber.d("Push rule match for event ${event.eventId}") val action = pushRule.getActions().toNotificationAction() if (action.shouldNotify) { resolver.resolveEvent(event, session, isNoisy = !action.soundName.isNullOrBlank()) } else { - Timber.v("Matched push rule is set to not notify") + Timber.d("Matched push rule is set to not notify") null } }