Add fallback notifications from UTDs to the push history (#5047)

This commit is contained in:
Jorge Martin Espinosa 2025-07-23 08:55:41 +02:00 committed by GitHub
parent d53457ec66
commit 7c982a30cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 93 additions and 9 deletions

View file

@ -236,7 +236,12 @@ class DefaultNotifiableEventResolver @Inject constructor(
}
NotificationContent.MessageLike.RoomEncrypted -> {
Timber.tag(loggerTag.value).w("Notification with encrypted content -> fallback")
val fallbackNotifiableEvent = fallbackNotificationFactory.create(userId, roomId, eventId)
val fallbackNotifiableEvent = fallbackNotificationFactory.create(
sessionId = userId,
roomId = roomId,
eventId = eventId,
cause = "Unable to decrypt event content",
)
ResolvedPushEvent.Event(fallbackNotifiableEvent)
}
is NotificationContent.MessageLike.RoomRedaction -> {

View file

@ -24,6 +24,7 @@ class FallbackNotificationFactory @Inject constructor(
sessionId: SessionId,
roomId: RoomId,
eventId: EventId,
cause: String?,
): FallbackNotifiableEvent = FallbackNotifiableEvent(
sessionId = sessionId,
roomId = roomId,
@ -34,5 +35,6 @@ class FallbackNotificationFactory @Inject constructor(
isUpdated = false,
timestamp = clock.epochMillis(),
description = stringProvider.getString(R.string.notification_fallback_content),
cause = cause,
)
}

View file

@ -25,4 +25,5 @@ data class FallbackNotifiableEvent(
override val isRedacted: Boolean,
override val isUpdated: Boolean,
val timestamp: Long,
val cause: String?,
) : NotifiableEvent

View file

@ -27,6 +27,7 @@ import io.element.android.libraries.push.impl.notifications.FallbackNotification
import io.element.android.libraries.push.impl.notifications.NotificationEventRequest
import io.element.android.libraries.push.impl.notifications.NotificationResolverQueue
import io.element.android.libraries.push.impl.notifications.channels.NotificationChannels
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
import io.element.android.libraries.push.impl.notifications.model.NotifiableRingingCallEvent
import io.element.android.libraries.push.impl.notifications.model.ResolvedPushEvent
@ -90,13 +91,23 @@ class DefaultPushHandler @Inject constructor(
} else {
result.fold(
onSuccess = {
pushHistoryService.onSuccess(
providerInfo = request.providerInfo,
eventId = request.eventId,
roomId = request.roomId,
sessionId = request.sessionId,
comment = "Push handled successfully",
)
if (it is ResolvedPushEvent.Event && it.notifiableEvent is FallbackNotifiableEvent) {
pushHistoryService.onUnableToResolveEvent(
providerInfo = request.providerInfo,
eventId = request.eventId,
roomId = request.roomId,
sessionId = request.sessionId,
reason = it.notifiableEvent.cause.orEmpty(),
)
} else {
pushHistoryService.onSuccess(
providerInfo = request.providerInfo,
eventId = request.eventId,
roomId = request.roomId,
sessionId = request.sessionId,
comment = "Push handled successfully",
)
}
},
onFailure = { exception ->
if (exception is NotificationResolverException.EventFilteredOut) {
@ -140,7 +151,14 @@ class DefaultPushHandler @Inject constructor(
}
else -> {
Timber.tag(loggerTag.value).e(exception, "Failed to resolve push event")
ResolvedPushEvent.Event(fallbackNotificationFactory.create(request.sessionId, request.roomId, request.eventId))
ResolvedPushEvent.Event(
fallbackNotificationFactory.create(
sessionId = request.sessionId,
roomId = request.roomId,
eventId = request.eventId,
cause = exception.message,
)
)
}
}
}.getOrNull() ?: continue