Browse Source

Improve extension to fix a copy paste issue.

pull/3592/head
Benoit Marty 2 weeks ago
parent
commit
fd142c16d9
  1. 13
      libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotifiableEventResolver.kt

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

@ -103,7 +103,7 @@ class DefaultNotifiableEventResolver @Inject constructor( @@ -103,7 +103,7 @@ class DefaultNotifiableEventResolver @Inject constructor(
timestamp = this.timestamp,
senderDisambiguatedDisplayName = senderDisambiguatedDisplayName,
body = messageBody,
imageUriString = fetchImageIfPresent(client)?.toString(),
imageUriString = content.fetchImageIfPresent(client)?.toString(),
roomName = roomDisplayName,
roomIsDm = isDm,
roomAvatarPath = roomAvatarUrl,
@ -148,7 +148,6 @@ class DefaultNotifiableEventResolver @Inject constructor( @@ -148,7 +148,6 @@ class DefaultNotifiableEventResolver @Inject constructor(
timestamp = this.timestamp,
senderDisambiguatedDisplayName = getDisambiguatedDisplayName(content.senderId),
body = stringProvider.getString(CommonStrings.common_call_invite),
imageUriString = fetchImageIfPresent(client)?.toString(),
roomName = roomDisplayName,
roomIsDm = isDm,
roomAvatarPath = roomAvatarUrl,
@ -288,10 +287,8 @@ class DefaultNotifiableEventResolver @Inject constructor( @@ -288,10 +287,8 @@ class DefaultNotifiableEventResolver @Inject constructor(
}
}
private suspend fun NotificationData.fetchImageIfPresent(client: MatrixClient): Uri? {
val fileResult = when (val content = this.content) {
is NotificationContent.MessageLike.RoomMessage -> {
when (val messageType = content.messageType) {
private suspend fun NotificationContent.MessageLike.RoomMessage.fetchImageIfPresent(client: MatrixClient): Uri? {
val fileResult = when (val messageType = messageType) {
is ImageMessageType -> notificationMediaRepoFactory.create(client)
.getMediaFile(
mediaSource = messageType.source,
@ -301,9 +298,7 @@ class DefaultNotifiableEventResolver @Inject constructor( @@ -301,9 +298,7 @@ class DefaultNotifiableEventResolver @Inject constructor(
is VideoMessageType -> null // Use the thumbnail here?
else -> null
}
}
else -> null
} ?: return null
?: return null
return fileResult
.onFailure {

Loading…
Cancel
Save