diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/exception/NotificationResolverException.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/exception/NotificationResolverException.kt index fd3adf2592..a83fbd1e23 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/exception/NotificationResolverException.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/exception/NotificationResolverException.kt @@ -22,6 +22,11 @@ sealed class NotificationResolverException : Exception() { */ data object EventFilteredOut : NotificationResolverException() + /** + * The event was found but it has been redacted. + */ + data object EventRedacted : NotificationResolverException() + /** * An unexpected error occurred while trying to resolve the event. */ diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt index 59d95af05b..238a8d988c 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/RustNotificationService.kt @@ -66,6 +66,10 @@ class RustNotificationService( Timber.d("Could not retrieve event for notification with $eventId - event filtered out") put(eventId, Result.failure(NotificationResolverException.EventFilteredOut)) } + NotificationStatus.EventRedacted -> { + Timber.d("Could not retrieve event for notification with $eventId - event redacted") + put(eventId, Result.failure(NotificationResolverException.EventRedacted)) + } } } is BatchNotificationResult.Error -> { diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandler.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandler.kt index 3f13f33818..0053a18838 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandler.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandler.kt @@ -124,6 +124,14 @@ class DefaultPushHandler( sessionId = request.sessionId, comment = "Push handled successfully but notification was filtered out", ) + } else if (exception is NotificationResolverException.EventRedacted) { + pushHistoryService.onSuccess( + providerInfo = request.providerInfo, + eventId = request.eventId, + roomId = request.roomId, + sessionId = request.sessionId, + comment = "Push handled successfully but event has been redacted", + ) } else { val reason = when (exception) { is NotificationResolverException.EventNotFound -> "Event not found" @@ -155,6 +163,10 @@ class DefaultPushHandler( // Do nothing, we don't want to show a notification for filtered out events null } + is NotificationResolverException.EventRedacted -> { + // Do nothing, we don't want to show a notification for redacted events + null + } else -> { Timber.tag(loggerTag.value).e(exception, "Failed to resolve push event") ResolvedPushEvent.Event(