Add unit test on RustNotificationService
And fix mapping error.
This commit is contained in:
parent
145c40ddfa
commit
6fa585f4c8
15 changed files with 242 additions and 50 deletions
|
|
@ -24,7 +24,6 @@ import io.element.android.libraries.matrix.api.core.UserId
|
|||
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
||||
import io.element.android.libraries.matrix.api.notification.NotificationData
|
||||
import io.element.android.libraries.matrix.api.permalink.PermalinkParser
|
||||
import io.element.android.libraries.matrix.api.room.RoomMembershipState
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.AudioMessageType
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.EmoteMessageType
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
||||
|
|
@ -76,7 +75,6 @@ class DefaultNotifiableEventResolver @Inject constructor(
|
|||
val client = matrixClientProvider.getOrRestore(sessionId).getOrNull() ?: return null
|
||||
val notificationService = client.notificationService()
|
||||
val notificationData = notificationService.getNotification(
|
||||
userId = sessionId,
|
||||
roomId = roomId,
|
||||
eventId = eventId,
|
||||
).onFailure {
|
||||
|
|
@ -113,30 +111,26 @@ class DefaultNotifiableEventResolver @Inject constructor(
|
|||
hasMentionOrReply = hasMention,
|
||||
)
|
||||
}
|
||||
is NotificationContent.StateEvent.RoomMemberContent -> {
|
||||
if (content.membershipState == RoomMembershipState.INVITE) {
|
||||
InviteNotifiableEvent(
|
||||
sessionId = userId,
|
||||
roomId = roomId,
|
||||
eventId = eventId,
|
||||
editedEventId = null,
|
||||
canBeReplaced = true,
|
||||
roomName = roomDisplayName,
|
||||
noisy = isNoisy,
|
||||
timestamp = this.timestamp,
|
||||
soundName = null,
|
||||
isRedacted = false,
|
||||
isUpdated = false,
|
||||
description = descriptionFromRoomMembershipInvite(isDirect),
|
||||
// TODO check if type is needed anymore
|
||||
type = null,
|
||||
// TODO check if title is needed anymore
|
||||
title = null,
|
||||
)
|
||||
} else {
|
||||
Timber.tag(loggerTag.value).d("Ignoring notification state event for membership ${content.membershipState}")
|
||||
null
|
||||
}
|
||||
is NotificationContent.Invite -> {
|
||||
InviteNotifiableEvent(
|
||||
sessionId = userId,
|
||||
roomId = roomId,
|
||||
eventId = eventId,
|
||||
editedEventId = null,
|
||||
canBeReplaced = true,
|
||||
roomName = roomDisplayName,
|
||||
noisy = isNoisy,
|
||||
timestamp = this.timestamp,
|
||||
soundName = null,
|
||||
isRedacted = false,
|
||||
isUpdated = false,
|
||||
// TODO We could use the senderId here
|
||||
description = descriptionFromRoomMembershipInvite(isDirect),
|
||||
// TODO check if type is needed anymore
|
||||
type = null,
|
||||
// TODO check if title is needed anymore
|
||||
title = null,
|
||||
)
|
||||
}
|
||||
NotificationContent.MessageLike.CallAnswer,
|
||||
NotificationContent.MessageLike.CallCandidates,
|
||||
|
|
@ -203,6 +197,7 @@ class DefaultNotifiableEventResolver @Inject constructor(
|
|||
NotificationContent.MessageLike.Sticker -> null.also {
|
||||
Timber.tag(loggerTag.value).d("Ignoring notification for sticker")
|
||||
}
|
||||
is NotificationContent.StateEvent.RoomMemberContent,
|
||||
NotificationContent.StateEvent.PolicyRuleRoom,
|
||||
NotificationContent.StateEvent.PolicyRuleServer,
|
||||
NotificationContent.StateEvent.PolicyRuleUser,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class DefaultOnMissedCallNotificationHandler @Inject constructor(
|
|||
// Resolve the event and add a notification for it, at this point it should no longer be a ringing one
|
||||
val notificationData = matrixClientProvider.getOrRestore(sessionId).getOrNull()
|
||||
?.notificationService()
|
||||
?.getNotification(sessionId, roomId, eventId)
|
||||
?.getNotification(roomId, eventId)
|
||||
?.getOrNull()
|
||||
?: return
|
||||
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ class DefaultNotifiableEventResolverTest {
|
|||
notificationResult = Result.success(
|
||||
createNotificationData(
|
||||
content = NotificationContent.StateEvent.RoomMemberContent(
|
||||
userId = A_USER_ID_2.value,
|
||||
sender = A_USER_ID_2,
|
||||
membershipState = RoomMembershipState.INVITE
|
||||
),
|
||||
isDirect = false,
|
||||
|
|
@ -405,7 +405,7 @@ class DefaultNotifiableEventResolverTest {
|
|||
notificationResult = Result.success(
|
||||
createNotificationData(
|
||||
content = NotificationContent.StateEvent.RoomMemberContent(
|
||||
userId = A_USER_ID_2.value,
|
||||
sender = A_USER_ID_2,
|
||||
membershipState = RoomMembershipState.INVITE
|
||||
),
|
||||
isDirect = true,
|
||||
|
|
@ -440,7 +440,7 @@ class DefaultNotifiableEventResolverTest {
|
|||
notificationResult = Result.success(
|
||||
createNotificationData(
|
||||
content = NotificationContent.StateEvent.RoomMemberContent(
|
||||
userId = A_USER_ID_2.value,
|
||||
sender = A_USER_ID_2,
|
||||
membershipState = RoomMembershipState.JOIN
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue