diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/EventMatchCondition.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/EventMatchCondition.kt index 9fdf848288..157cee8219 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/EventMatchCondition.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/EventMatchCondition.kt @@ -39,8 +39,9 @@ class EventMatchCondition( override fun technicalDescription() = "'$key' matches '$pattern'" fun isSatisfied(event: Event): Boolean { - val rawJson: Map<*, *> = event.mxDecryptionResult?.payload ?: MoshiProvider.providesMoshi().adapter(Event::class.java).toJsonValue(event) as? Map<*, *> - ?: return false + val rawJson: Map<*, *> = event.mxDecryptionResult?.payload + ?: MoshiProvider.providesMoshi().adapter(Event::class.java).toJsonValue(event) as? Map<*, *> + ?: return false val value = extractField(rawJson, key) ?: return false // The match is performed case-insensitively, and must match the entire value of diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt index 14a36d9922..e1026bbf04 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotifiableEventResolver.kt @@ -66,9 +66,6 @@ class NotifiableEventResolver @Inject constructor( private val buildMeta: BuildMeta, ) { - private val nonEncryptedNotifiableEventTypes: List = - listOf(EventType.MESSAGE) + EventType.POLL_START.values + EventType.POLL_END.values + EventType.STATE_ROOM_BEACON_INFO.values - suspend fun resolveEvent(event: Event, session: Session, isNoisy: Boolean): NotifiableEvent? { val roomID = event.roomId ?: return null val eventId = event.eventId ?: return null @@ -76,9 +73,8 @@ class NotifiableEventResolver @Inject constructor( return resolveStateRoomEvent(event, session, canBeReplaced = false, isNoisy = isNoisy) } val timelineEvent = session.getRoom(roomID)?.getTimelineEvent(eventId) ?: return null - return when (event.getClearType()) { - in nonEncryptedNotifiableEventTypes, - EventType.ENCRYPTED -> { + return when { + event.supportsNotification() || event.type == EventType.ENCRYPTED -> { resolveMessageEvent(timelineEvent, session, canBeReplaced = false, isNoisy = isNoisy) } else -> { @@ -163,8 +159,8 @@ class NotifiableEventResolver @Inject constructor( } else { event.attemptToDecryptIfNeeded(session) // only convert encrypted messages to NotifiableMessageEvents - when (event.root.getClearType()) { - in nonEncryptedNotifiableEventTypes -> { + when { + event.root.supportsNotification() -> { val body = displayableEventFormatter.format(event, isDm = room.roomSummary()?.isDirect.orFalse(), appendAuthor = false).toString() val roomName = room.roomSummary()?.displayName ?: "" val senderDisplayName = event.senderInfo.disambiguatedDisplayName