Skip to content

Commit 1a7ce36

Browse files
committed
refactor: rename CallNotify to RtcNotification to match new event
1 parent be52447 commit 1a7ce36

File tree

10 files changed

+30
-30
lines changed

10 files changed

+30
-30
lines changed

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/ActiveCallManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class DefaultActiveCallManager(
133133
}
134134

135135
appForegroundStateService.updateHasRingingCall(true)
136-
Timber.tag(tag).d("Received incoming call for room id: ${notificationData.roomId}, ringDuration: $ringDuration")
136+
Timber.tag(tag).d("Received incoming call for room id: ${notificationData.roomId}, ringDuration(ms): $ringDuration")
137137
if (activeCall.value != null) {
138138
displayMissedCallNotification(notificationData)
139139
Timber.tag(tag).w("Already have an active call, ignoring incoming call: $notificationData")

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/notification/NotificationData.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ sealed interface NotificationContent {
4949
val senderId: UserId,
5050
) : MessageLike
5151

52-
data class CallNotify(
52+
data class RtcNotification(
5353
val senderId: UserId,
54-
val type: CallNotifyType,
54+
val type: RtcNotificationType,
5555
val expirationTimestampMillis: Long
5656
) : MessageLike
5757

@@ -119,7 +119,7 @@ sealed interface NotificationContent {
119119
) : NotificationContent
120120
}
121121

122-
enum class CallNotifyType {
122+
enum class RtcNotificationType {
123123
RING,
124124
NOTIFY
125125
}

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/TimelineEventToNotificationContentMapper.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package io.element.android.libraries.matrix.impl.notification
1010
import io.element.android.libraries.core.extensions.runCatchingExceptions
1111
import io.element.android.libraries.matrix.api.core.EventId
1212
import io.element.android.libraries.matrix.api.core.UserId
13-
import io.element.android.libraries.matrix.api.notification.CallNotifyType
13+
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
1414
import io.element.android.libraries.matrix.api.notification.NotificationContent
1515
import io.element.android.libraries.matrix.impl.room.member.RoomMemberMapper
1616
import io.element.android.libraries.matrix.impl.timeline.item.event.EventMessageMapper
@@ -78,7 +78,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon
7878
MessageLikeEventContent.CallCandidates -> NotificationContent.MessageLike.CallCandidates
7979
MessageLikeEventContent.CallHangup -> NotificationContent.MessageLike.CallHangup
8080
MessageLikeEventContent.CallInvite -> NotificationContent.MessageLike.CallInvite(senderId)
81-
is MessageLikeEventContent.RtcNotification -> NotificationContent.MessageLike.CallNotify(
81+
is MessageLikeEventContent.RtcNotification -> NotificationContent.MessageLike.RtcNotification(
8282
senderId = senderId,
8383
type = notificationType.map(),
8484
expirationTimestampMillis = expirationTs.toLong()
@@ -105,7 +105,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon
105105
}
106106
}
107107

108-
private fun RtcNotificationType.map(): CallNotifyType = when (this) {
109-
RtcNotificationType.NOTIFICATION -> CallNotifyType.NOTIFY
110-
RtcNotificationType.RING -> CallNotifyType.RING
108+
private fun RtcNotificationType.map(): RtcNotificationType = when (this) {
109+
RtcNotificationType.NOTIFICATION -> RtcNotificationType.NOTIFY
110+
RtcNotificationType.RING -> RtcNotificationType.RING
111111
}

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/CallNotificationEventResolver.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import io.element.android.libraries.core.extensions.runCatchingExceptions
1414
import io.element.android.libraries.matrix.api.MatrixClientProvider
1515
import io.element.android.libraries.matrix.api.core.SessionId
1616
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
17-
import io.element.android.libraries.matrix.api.notification.CallNotifyType
17+
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
1818
import io.element.android.libraries.matrix.api.notification.NotificationContent
1919
import io.element.android.libraries.matrix.api.notification.NotificationData
2020
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
@@ -58,13 +58,13 @@ class DefaultCallNotificationEventResolver(
5858
notificationData: NotificationData,
5959
forceNotify: Boolean
6060
): Result<NotifiableEvent> = runCatchingExceptions {
61-
val content = notificationData.content as? NotificationContent.MessageLike.CallNotify
61+
val content = notificationData.content as? NotificationContent.MessageLike.RtcNotification
6262
?: throw NotificationResolverException.UnknownError("content is not a call notify")
6363

6464
val previousRingingCallStatus = appForegroundStateService.hasRingingCall.value
6565
// We need the sync service working to get the updated room info
6666
val isRoomCallActive = runCatchingExceptions {
67-
if (content.type == CallNotifyType.RING) {
67+
if (content.type == RtcNotificationType.RING) {
6868
appForegroundStateService.updateHasRingingCall(true)
6969

7070
val client = clientProvider.getOrRestore(
@@ -90,7 +90,7 @@ class DefaultCallNotificationEventResolver(
9090
}.getOrDefault(false)
9191

9292
notificationData.run {
93-
if (content.type == CallNotifyType.RING && isRoomCallActive && !forceNotify) {
93+
if (content.type == RtcNotificationType.RING && isRoomCallActive && !forceNotify) {
9494
NotifiableRingingCallEvent(
9595
sessionId = sessionId,
9696
roomId = roomId,
@@ -104,7 +104,7 @@ class DefaultCallNotificationEventResolver(
104104
description = stringProvider.getString(R.string.notification_incoming_call),
105105
senderDisambiguatedDisplayName = getDisambiguatedDisplayName(content.senderId),
106106
roomAvatarUrl = roomAvatarUrl,
107-
callNotifyType = content.type,
107+
rtcNotificationType = content.type,
108108
senderId = content.senderId,
109109
senderAvatarUrl = senderAvatarUrl,
110110
expirationTimestamp = content.expirationTimestampMillis,

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotifiableEventResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class DefaultNotifiableEventResolver(
199199
)
200200
ResolvedPushEvent.Event(notifiableMessageEvent)
201201
}
202-
is NotificationContent.MessageLike.CallNotify -> {
202+
is NotificationContent.MessageLike.RtcNotification -> {
203203
val notifiableEvent = callNotificationEventResolver.resolveEvent(userId, this).getOrThrow()
204204
ResolvedPushEvent.Event(notifiableEvent)
205205
}

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/model/NotifiableRingingCallEvent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import io.element.android.libraries.matrix.api.core.EventId
1111
import io.element.android.libraries.matrix.api.core.RoomId
1212
import io.element.android.libraries.matrix.api.core.SessionId
1313
import io.element.android.libraries.matrix.api.core.UserId
14-
import io.element.android.libraries.matrix.api.notification.CallNotifyType
14+
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
1515

1616
data class NotifiableRingingCallEvent(
1717
override val sessionId: SessionId,
@@ -27,7 +27,7 @@ data class NotifiableRingingCallEvent(
2727
val senderDisambiguatedDisplayName: String?,
2828
val senderAvatarUrl: String?,
2929
val roomAvatarUrl: String? = null,
30-
val callNotifyType: CallNotifyType,
30+
val rtcNotificationType: RtcNotificationType,
3131
val timestamp: Long,
3232
val expirationTimestamp: Long,
3333
) : NotifiableEvent

libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultCallNotificationEventResolverTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package io.element.android.libraries.push.impl.notifications
99

1010
import com.google.common.truth.Truth.assertThat
11-
import io.element.android.libraries.matrix.api.notification.CallNotifyType
11+
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
1212
import io.element.android.libraries.matrix.api.notification.NotificationContent
1313
import io.element.android.libraries.matrix.test.AN_EVENT_ID
1414
import io.element.android.libraries.matrix.test.A_ROOM_ID
@@ -62,11 +62,11 @@ class DefaultCallNotificationEventResolverTest {
6262
senderDisambiguatedDisplayName = A_USER_NAME_2,
6363
senderAvatarUrl = null,
6464
expirationTimestamp = 1567L,
65-
callNotifyType = CallNotifyType.RING,
65+
rtcNotificationType = RtcNotificationType.RING,
6666
)
6767

6868
val notificationData = aNotificationData(
69-
content = NotificationContent.MessageLike.CallNotify(A_USER_ID_2, CallNotifyType.RING, 1567)
69+
content = NotificationContent.MessageLike.RtcNotification(A_USER_ID_2, RtcNotificationType.RING, 1567)
7070
)
7171
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
7272
assertThat(result.getOrNull()).isEqualTo(expectedResult)
@@ -110,7 +110,7 @@ class DefaultCallNotificationEventResolverTest {
110110
)
111111

112112
val notificationData = aNotificationData(
113-
content = NotificationContent.MessageLike.CallNotify(A_USER_ID_2, CallNotifyType.NOTIFY, 0)
113+
content = NotificationContent.MessageLike.RtcNotification(A_USER_ID_2, RtcNotificationType.NOTIFY, 0)
114114
)
115115
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
116116
assertThat(result.getOrNull()).isEqualTo(expectedResult)
@@ -154,7 +154,7 @@ class DefaultCallNotificationEventResolverTest {
154154
)
155155

156156
val notificationData = aNotificationData(
157-
content = NotificationContent.MessageLike.CallNotify(A_USER_ID_2, CallNotifyType.RING, 0)
157+
content = NotificationContent.MessageLike.RtcNotification(A_USER_ID_2, RtcNotificationType.RING, 0)
158158
)
159159
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
160160
assertThat(result.getOrNull()).isEqualTo(expectedResult)

libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotifiableEventResolverTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.google.common.truth.Truth.assertThat
1212
import io.element.android.libraries.matrix.api.core.EventId
1313
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
1414
import io.element.android.libraries.matrix.api.media.MediaSource
15-
import io.element.android.libraries.matrix.api.notification.CallNotifyType
15+
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
1616
import io.element.android.libraries.matrix.api.notification.NotificationContent
1717
import io.element.android.libraries.matrix.api.notification.NotificationData
1818
import io.element.android.libraries.matrix.api.room.RoomMembershipState
@@ -693,9 +693,9 @@ class DefaultNotifiableEventResolverTest {
693693
notificationResult = Result.success(
694694
mapOf(
695695
AN_EVENT_ID to Result.success(aNotificationData(
696-
content = NotificationContent.MessageLike.CallNotify(
696+
content = NotificationContent.MessageLike.RtcNotification(
697697
A_USER_ID_2,
698-
CallNotifyType.NOTIFY,
698+
RtcNotificationType.NOTIFY,
699699
0
700700
),
701701
))

libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fixtures/NotifiableEventFixture.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import io.element.android.libraries.matrix.api.core.RoomId
1212
import io.element.android.libraries.matrix.api.core.SessionId
1313
import io.element.android.libraries.matrix.api.core.ThreadId
1414
import io.element.android.libraries.matrix.api.core.UserId
15-
import io.element.android.libraries.matrix.api.notification.CallNotifyType
15+
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
1616
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
1717
import io.element.android.libraries.matrix.test.AN_AVATAR_URL
1818
import io.element.android.libraries.matrix.test.AN_EVENT_ID
@@ -119,7 +119,7 @@ fun aNotifiableCallEvent(
119119
senderName: String? = null,
120120
roomAvatarUrl: String? = AN_AVATAR_URL,
121121
senderAvatarUrl: String? = AN_AVATAR_URL,
122-
callNotifyType: CallNotifyType = CallNotifyType.NOTIFY,
122+
rtcNotificationType: RtcNotificationType = RtcNotificationType.NOTIFY,
123123
timestamp: Long = 0L,
124124
expirationTimestamp: Long = 0L,
125125
) = NotifiableRingingCallEvent(
@@ -138,5 +138,5 @@ fun aNotifiableCallEvent(
138138
senderId = senderId,
139139
roomAvatarUrl = roomAvatarUrl,
140140
senderAvatarUrl = senderAvatarUrl,
141-
callNotifyType = callNotifyType,
141+
rtcNotificationType = rtcNotificationType,
142142
)

libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.core.RoomId
2020
import io.element.android.libraries.matrix.api.core.SessionId
2121
import io.element.android.libraries.matrix.api.core.UserId
2222
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
23-
import io.element.android.libraries.matrix.api.notification.CallNotifyType
23+
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
2424
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
2525
import io.element.android.libraries.matrix.test.AN_EVENT_ID
2626
import io.element.android.libraries.matrix.test.AN_EVENT_ID_2
@@ -388,7 +388,7 @@ class DefaultPushHandlerTest {
388388
mapOf(
389389
request to Result.success(
390390
ResolvedPushEvent.Event(
391-
aNotifiableCallEvent(callNotifyType = CallNotifyType.RING, timestamp = Instant.now().toEpochMilli())
391+
aNotifiableCallEvent(rtcNotificationType = RtcNotificationType.RING, timestamp = Instant.now().toEpochMilli())
392392
)
393393
)
394394
)

0 commit comments

Comments
 (0)