mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:05:28 +00:00
Render push notifications for live location share starts
This commit is contained in:
+19
-2
@@ -303,6 +303,24 @@ class DefaultNotifiableEventResolver(
|
||||
Timber.tag(loggerTag.value).d("Ignoring notification for beacon")
|
||||
throw NotificationResolverException.EventFilteredOut
|
||||
}
|
||||
is NotificationContent.StateEvent.BeaconInfo -> {
|
||||
val notifiableEventMessage = buildNotifiableMessageEvent(
|
||||
sessionId = userId,
|
||||
senderId = content.senderId,
|
||||
roomId = roomId,
|
||||
eventId = eventId,
|
||||
noisy = isNoisy,
|
||||
timestamp = this.timestamp,
|
||||
senderDisambiguatedDisplayName = getDisambiguatedDisplayName(content.senderId),
|
||||
body = stringProvider.getString(R.string.notification_live_location_started_body),
|
||||
imageUriString = null,
|
||||
roomName = roomDisplayName,
|
||||
roomIsDm = isDm,
|
||||
roomAvatarPath = roomAvatarUrl,
|
||||
senderAvatarPath = senderAvatarUrl,
|
||||
)
|
||||
ResolvedPushEvent.Event(notifiableEventMessage)
|
||||
}
|
||||
is NotificationContent.StateEvent.RoomMemberContent,
|
||||
NotificationContent.StateEvent.PolicyRuleRoom,
|
||||
NotificationContent.StateEvent.PolicyRuleServer,
|
||||
@@ -322,8 +340,7 @@ class DefaultNotifiableEventResolver(
|
||||
NotificationContent.StateEvent.RoomTombstone,
|
||||
is NotificationContent.StateEvent.RoomTopic,
|
||||
NotificationContent.StateEvent.SpaceChild,
|
||||
NotificationContent.StateEvent.SpaceParent,
|
||||
NotificationContent.StateEvent.BeaconInfo -> {
|
||||
NotificationContent.StateEvent.SpaceParent -> {
|
||||
Timber.tag(loggerTag.value).d("Ignoring notification for state event ${content.javaClass.simpleName}")
|
||||
throw NotificationResolverException.EventFilteredOut
|
||||
}
|
||||
|
||||
+22
@@ -416,6 +416,27 @@ class DefaultNotifiableEventResolverTest : RobolectricTest() {
|
||||
assertThat(result.getEvent(request)).isEqualTo(Result.success(expectedResult))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `resolve live location share start`() = runTest {
|
||||
val sut = createDefaultNotifiableEventResolver(
|
||||
notificationResult = Result.success(
|
||||
mapOf(
|
||||
AN_EVENT_ID to Result.success(aNotificationData(
|
||||
content = NotificationContent.StateEvent.BeaconInfo(
|
||||
senderId = A_USER_ID_2,
|
||||
),
|
||||
))
|
||||
)
|
||||
)
|
||||
)
|
||||
val request = aPushRequest(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID, "firebase")
|
||||
val result = sut.resolveEvents(A_SESSION_ID, listOf(request))
|
||||
val expectedResult = ResolvedPushEvent.Event(
|
||||
aNotifiableMessageEvent(body = "Started sharing their live location")
|
||||
)
|
||||
assertThat(result.getEvent(request)).isEqualTo(Result.success(expectedResult))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `resolve RoomMemberContent invite room`() = runTest {
|
||||
val sut = createDefaultNotifiableEventResolver(
|
||||
@@ -829,6 +850,7 @@ class DefaultNotifiableEventResolverTest : RobolectricTest() {
|
||||
testNoResults(NotificationContent.MessageLike.KeyVerificationDone)
|
||||
testNoResults(NotificationContent.MessageLike.ReactionContent(relatedEventId = AN_EVENT_ID_2.value))
|
||||
testNoResults(NotificationContent.MessageLike.Sticker)
|
||||
testNoResults(NotificationContent.MessageLike.Beacon)
|
||||
testNoResults(NotificationContent.StateEvent.PolicyRuleRoom)
|
||||
testNoResults(NotificationContent.StateEvent.PolicyRuleServer)
|
||||
testNoResults(NotificationContent.StateEvent.PolicyRuleUser)
|
||||
|
||||
Reference in New Issue
Block a user