refactor: rename CallNotify to RtcNotification to match new event
This commit is contained in:
parent
2ecd4ecaf5
commit
f9fa38f229
10 changed files with 30 additions and 30 deletions
|
|
@ -133,7 +133,7 @@ class DefaultActiveCallManager(
|
||||||
}
|
}
|
||||||
|
|
||||||
appForegroundStateService.updateHasRingingCall(true)
|
appForegroundStateService.updateHasRingingCall(true)
|
||||||
Timber.tag(tag).d("Received incoming call for room id: ${notificationData.roomId}, ringDuration: $ringDuration")
|
Timber.tag(tag).d("Received incoming call for room id: ${notificationData.roomId}, ringDuration(ms): $ringDuration")
|
||||||
if (activeCall.value != null) {
|
if (activeCall.value != null) {
|
||||||
displayMissedCallNotification(notificationData)
|
displayMissedCallNotification(notificationData)
|
||||||
Timber.tag(tag).w("Already have an active call, ignoring incoming call: $notificationData")
|
Timber.tag(tag).w("Already have an active call, ignoring incoming call: $notificationData")
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ sealed interface NotificationContent {
|
||||||
val senderId: UserId,
|
val senderId: UserId,
|
||||||
) : MessageLike
|
) : MessageLike
|
||||||
|
|
||||||
data class CallNotify(
|
data class RtcNotification(
|
||||||
val senderId: UserId,
|
val senderId: UserId,
|
||||||
val type: CallNotifyType,
|
val type: RtcNotificationType,
|
||||||
val expirationTimestampMillis: Long
|
val expirationTimestampMillis: Long
|
||||||
) : MessageLike
|
) : MessageLike
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ sealed interface NotificationContent {
|
||||||
) : NotificationContent
|
) : NotificationContent
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class CallNotifyType {
|
enum class RtcNotificationType {
|
||||||
RING,
|
RING,
|
||||||
NOTIFY
|
NOTIFY
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ package io.element.android.libraries.matrix.impl.notification
|
||||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
||||||
import io.element.android.libraries.matrix.impl.room.member.RoomMemberMapper
|
import io.element.android.libraries.matrix.impl.room.member.RoomMemberMapper
|
||||||
import io.element.android.libraries.matrix.impl.timeline.item.event.EventMessageMapper
|
import io.element.android.libraries.matrix.impl.timeline.item.event.EventMessageMapper
|
||||||
|
|
@ -78,7 +78,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon
|
||||||
MessageLikeEventContent.CallCandidates -> NotificationContent.MessageLike.CallCandidates
|
MessageLikeEventContent.CallCandidates -> NotificationContent.MessageLike.CallCandidates
|
||||||
MessageLikeEventContent.CallHangup -> NotificationContent.MessageLike.CallHangup
|
MessageLikeEventContent.CallHangup -> NotificationContent.MessageLike.CallHangup
|
||||||
MessageLikeEventContent.CallInvite -> NotificationContent.MessageLike.CallInvite(senderId)
|
MessageLikeEventContent.CallInvite -> NotificationContent.MessageLike.CallInvite(senderId)
|
||||||
is MessageLikeEventContent.RtcNotification -> NotificationContent.MessageLike.CallNotify(
|
is MessageLikeEventContent.RtcNotification -> NotificationContent.MessageLike.RtcNotification(
|
||||||
senderId = senderId,
|
senderId = senderId,
|
||||||
type = notificationType.map(),
|
type = notificationType.map(),
|
||||||
expirationTimestampMillis = expirationTs.toLong()
|
expirationTimestampMillis = expirationTs.toLong()
|
||||||
|
|
@ -105,7 +105,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun RtcNotificationType.map(): CallNotifyType = when (this) {
|
private fun RtcNotificationType.map(): RtcNotificationType = when (this) {
|
||||||
RtcNotificationType.NOTIFICATION -> CallNotifyType.NOTIFY
|
RtcNotificationType.NOTIFICATION -> RtcNotificationType.NOTIFY
|
||||||
RtcNotificationType.RING -> CallNotifyType.RING
|
RtcNotificationType.RING -> RtcNotificationType.RING
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||||
import io.element.android.libraries.matrix.api.MatrixClientProvider
|
import io.element.android.libraries.matrix.api.MatrixClientProvider
|
||||||
import io.element.android.libraries.matrix.api.core.SessionId
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
|
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
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.notification.NotificationData
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
||||||
|
|
@ -58,13 +58,13 @@ class DefaultCallNotificationEventResolver(
|
||||||
notificationData: NotificationData,
|
notificationData: NotificationData,
|
||||||
forceNotify: Boolean
|
forceNotify: Boolean
|
||||||
): Result<NotifiableEvent> = runCatchingExceptions {
|
): Result<NotifiableEvent> = runCatchingExceptions {
|
||||||
val content = notificationData.content as? NotificationContent.MessageLike.CallNotify
|
val content = notificationData.content as? NotificationContent.MessageLike.RtcNotification
|
||||||
?: throw NotificationResolverException.UnknownError("content is not a call notify")
|
?: throw NotificationResolverException.UnknownError("content is not a call notify")
|
||||||
|
|
||||||
val previousRingingCallStatus = appForegroundStateService.hasRingingCall.value
|
val previousRingingCallStatus = appForegroundStateService.hasRingingCall.value
|
||||||
// We need the sync service working to get the updated room info
|
// We need the sync service working to get the updated room info
|
||||||
val isRoomCallActive = runCatchingExceptions {
|
val isRoomCallActive = runCatchingExceptions {
|
||||||
if (content.type == CallNotifyType.RING) {
|
if (content.type == RtcNotificationType.RING) {
|
||||||
appForegroundStateService.updateHasRingingCall(true)
|
appForegroundStateService.updateHasRingingCall(true)
|
||||||
|
|
||||||
val client = clientProvider.getOrRestore(
|
val client = clientProvider.getOrRestore(
|
||||||
|
|
@ -90,7 +90,7 @@ class DefaultCallNotificationEventResolver(
|
||||||
}.getOrDefault(false)
|
}.getOrDefault(false)
|
||||||
|
|
||||||
notificationData.run {
|
notificationData.run {
|
||||||
if (content.type == CallNotifyType.RING && isRoomCallActive && !forceNotify) {
|
if (content.type == RtcNotificationType.RING && isRoomCallActive && !forceNotify) {
|
||||||
NotifiableRingingCallEvent(
|
NotifiableRingingCallEvent(
|
||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
|
|
@ -104,7 +104,7 @@ class DefaultCallNotificationEventResolver(
|
||||||
description = stringProvider.getString(R.string.notification_incoming_call),
|
description = stringProvider.getString(R.string.notification_incoming_call),
|
||||||
senderDisambiguatedDisplayName = getDisambiguatedDisplayName(content.senderId),
|
senderDisambiguatedDisplayName = getDisambiguatedDisplayName(content.senderId),
|
||||||
roomAvatarUrl = roomAvatarUrl,
|
roomAvatarUrl = roomAvatarUrl,
|
||||||
callNotifyType = content.type,
|
rtcNotificationType = content.type,
|
||||||
senderId = content.senderId,
|
senderId = content.senderId,
|
||||||
senderAvatarUrl = senderAvatarUrl,
|
senderAvatarUrl = senderAvatarUrl,
|
||||||
expirationTimestamp = content.expirationTimestampMillis,
|
expirationTimestamp = content.expirationTimestampMillis,
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ class DefaultNotifiableEventResolver(
|
||||||
)
|
)
|
||||||
ResolvedPushEvent.Event(notifiableMessageEvent)
|
ResolvedPushEvent.Event(notifiableMessageEvent)
|
||||||
}
|
}
|
||||||
is NotificationContent.MessageLike.CallNotify -> {
|
is NotificationContent.MessageLike.RtcNotification -> {
|
||||||
val notifiableEvent = callNotificationEventResolver.resolveEvent(userId, this).getOrThrow()
|
val notifiableEvent = callNotificationEventResolver.resolveEvent(userId, this).getOrThrow()
|
||||||
ResolvedPushEvent.Event(notifiableEvent)
|
ResolvedPushEvent.Event(notifiableEvent)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import io.element.android.libraries.matrix.api.core.EventId
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.matrix.api.core.SessionId
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
|
||||||
|
|
||||||
data class NotifiableRingingCallEvent(
|
data class NotifiableRingingCallEvent(
|
||||||
override val sessionId: SessionId,
|
override val sessionId: SessionId,
|
||||||
|
|
@ -27,7 +27,7 @@ data class NotifiableRingingCallEvent(
|
||||||
val senderDisambiguatedDisplayName: String?,
|
val senderDisambiguatedDisplayName: String?,
|
||||||
val senderAvatarUrl: String?,
|
val senderAvatarUrl: String?,
|
||||||
val roomAvatarUrl: String? = null,
|
val roomAvatarUrl: String? = null,
|
||||||
val callNotifyType: CallNotifyType,
|
val rtcNotificationType: RtcNotificationType,
|
||||||
val timestamp: Long,
|
val timestamp: Long,
|
||||||
val expirationTimestamp: Long,
|
val expirationTimestamp: Long,
|
||||||
) : NotifiableEvent
|
) : NotifiableEvent
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
package io.element.android.libraries.push.impl.notifications
|
package io.element.android.libraries.push.impl.notifications
|
||||||
|
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||||
|
|
@ -62,11 +62,11 @@ class DefaultCallNotificationEventResolverTest {
|
||||||
senderDisambiguatedDisplayName = A_USER_NAME_2,
|
senderDisambiguatedDisplayName = A_USER_NAME_2,
|
||||||
senderAvatarUrl = null,
|
senderAvatarUrl = null,
|
||||||
expirationTimestamp = 1567L,
|
expirationTimestamp = 1567L,
|
||||||
callNotifyType = CallNotifyType.RING,
|
rtcNotificationType = RtcNotificationType.RING,
|
||||||
)
|
)
|
||||||
|
|
||||||
val notificationData = aNotificationData(
|
val notificationData = aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallNotify(A_USER_ID_2, CallNotifyType.RING, 1567)
|
content = NotificationContent.MessageLike.RtcNotification(A_USER_ID_2, RtcNotificationType.RING, 1567)
|
||||||
)
|
)
|
||||||
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
|
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
|
||||||
assertThat(result.getOrNull()).isEqualTo(expectedResult)
|
assertThat(result.getOrNull()).isEqualTo(expectedResult)
|
||||||
|
|
@ -110,7 +110,7 @@ class DefaultCallNotificationEventResolverTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
val notificationData = aNotificationData(
|
val notificationData = aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallNotify(A_USER_ID_2, CallNotifyType.NOTIFY, 0)
|
content = NotificationContent.MessageLike.RtcNotification(A_USER_ID_2, RtcNotificationType.NOTIFY, 0)
|
||||||
)
|
)
|
||||||
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
|
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
|
||||||
assertThat(result.getOrNull()).isEqualTo(expectedResult)
|
assertThat(result.getOrNull()).isEqualTo(expectedResult)
|
||||||
|
|
@ -154,7 +154,7 @@ class DefaultCallNotificationEventResolverTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
val notificationData = aNotificationData(
|
val notificationData = aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallNotify(A_USER_ID_2, CallNotifyType.RING, 0)
|
content = NotificationContent.MessageLike.RtcNotification(A_USER_ID_2, RtcNotificationType.RING, 0)
|
||||||
)
|
)
|
||||||
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
|
val result = resolver.resolveEvent(A_SESSION_ID, notificationData)
|
||||||
assertThat(result.getOrNull()).isEqualTo(expectedResult)
|
assertThat(result.getOrNull()).isEqualTo(expectedResult)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
|
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
|
||||||
import io.element.android.libraries.matrix.api.media.MediaSource
|
import io.element.android.libraries.matrix.api.media.MediaSource
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
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.notification.NotificationData
|
||||||
import io.element.android.libraries.matrix.api.room.RoomMembershipState
|
import io.element.android.libraries.matrix.api.room.RoomMembershipState
|
||||||
|
|
@ -693,9 +693,9 @@ class DefaultNotifiableEventResolverTest {
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
mapOf(
|
mapOf(
|
||||||
AN_EVENT_ID to Result.success(aNotificationData(
|
AN_EVENT_ID to Result.success(aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallNotify(
|
content = NotificationContent.MessageLike.RtcNotification(
|
||||||
A_USER_ID_2,
|
A_USER_ID_2,
|
||||||
CallNotifyType.NOTIFY,
|
RtcNotificationType.NOTIFY,
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.matrix.api.core.SessionId
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
||||||
import io.element.android.libraries.matrix.test.AN_AVATAR_URL
|
import io.element.android.libraries.matrix.test.AN_AVATAR_URL
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
|
|
@ -119,7 +119,7 @@ fun aNotifiableCallEvent(
|
||||||
senderName: String? = null,
|
senderName: String? = null,
|
||||||
roomAvatarUrl: String? = AN_AVATAR_URL,
|
roomAvatarUrl: String? = AN_AVATAR_URL,
|
||||||
senderAvatarUrl: String? = AN_AVATAR_URL,
|
senderAvatarUrl: String? = AN_AVATAR_URL,
|
||||||
callNotifyType: CallNotifyType = CallNotifyType.NOTIFY,
|
rtcNotificationType: RtcNotificationType = RtcNotificationType.NOTIFY,
|
||||||
timestamp: Long = 0L,
|
timestamp: Long = 0L,
|
||||||
expirationTimestamp: Long = 0L,
|
expirationTimestamp: Long = 0L,
|
||||||
) = NotifiableRingingCallEvent(
|
) = NotifiableRingingCallEvent(
|
||||||
|
|
@ -138,5 +138,5 @@ fun aNotifiableCallEvent(
|
||||||
senderId = senderId,
|
senderId = senderId,
|
||||||
roomAvatarUrl = roomAvatarUrl,
|
roomAvatarUrl = roomAvatarUrl,
|
||||||
senderAvatarUrl = senderAvatarUrl,
|
senderAvatarUrl = senderAvatarUrl,
|
||||||
callNotifyType = callNotifyType,
|
rtcNotificationType = rtcNotificationType,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.matrix.api.core.SessionId
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
|
import io.element.android.libraries.matrix.api.exception.NotificationResolverException
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.RtcNotificationType
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID_2
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID_2
|
||||||
|
|
@ -388,7 +388,7 @@ class DefaultPushHandlerTest {
|
||||||
mapOf(
|
mapOf(
|
||||||
request to Result.success(
|
request to Result.success(
|
||||||
ResolvedPushEvent.Event(
|
ResolvedPushEvent.Event(
|
||||||
aNotifiableCallEvent(callNotifyType = CallNotifyType.RING, timestamp = Instant.now().toEpochMilli())
|
aNotifiableCallEvent(rtcNotificationType = RtcNotificationType.RING, timestamp = Instant.now().toEpochMilli())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue