From 765380ab95eeb13b968df7e2c58c9748a00e37df Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 May 2021 11:05:07 +0200 Subject: [PATCH] Fix potential issue with video message conten --- .../session/content/UploadContentWorker.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt index f8b58e3ad3..4dec8a9c78 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt @@ -176,10 +176,8 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter && params.compressBeforeSending) { fileToUpload = videoCompressor.compress(workingFile) .also { compressedFile -> - // Get new Video size - newAttachmentAttributes = NewAttachmentAttributes( - newFileSize = compressedFile.length() - ) + // Get new Video file size. For now video dimensions are not updated + newAttachmentAttributes = newAttachmentAttributes.copy(newFileSize = compressedFile.length()) } .also { filesToDelete.add(it) } } else { @@ -346,8 +344,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter val messageContent: MessageContent? = event.asDomain().content.toModel() val updatedContent = when (messageContent) { is MessageImageContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes) - is MessageVideoContent -> messageContent.update(url, encryptedFileInfo, thumbnailUrl, thumbnailEncryptedFileInfo, - newAttachmentAttributes.newFileSize) + is MessageVideoContent -> messageContent.update(url, encryptedFileInfo, thumbnailUrl, thumbnailEncryptedFileInfo, newAttachmentAttributes) is MessageFileContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize) is MessageAudioContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize) else -> messageContent @@ -378,14 +375,16 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter encryptedFileInfo: EncryptedFileInfo?, thumbnailUrl: String?, thumbnailEncryptedFileInfo: EncryptedFileInfo?, - size: Long): MessageVideoContent { + newAttachmentAttributes: NewAttachmentAttributes?): MessageVideoContent { return copy( url = if (encryptedFileInfo == null) url else null, encryptedFileInfo = encryptedFileInfo?.copy(url = url), videoInfo = videoInfo?.copy( thumbnailUrl = if (thumbnailEncryptedFileInfo == null) thumbnailUrl else null, thumbnailFile = thumbnailEncryptedFileInfo?.copy(url = thumbnailUrl), - size = size + width = newAttachmentAttributes?.newWidth ?: videoInfo.width, + height = newAttachmentAttributes?.newHeight ?: videoInfo.height, + size = newAttachmentAttributes?.newFileSize ?: videoInfo.size ) ) }