From c1c9f53015950d7db20379dbbb7de0d6831d573a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 16 Oct 2024 14:57:30 +0200 Subject: [PATCH] Fix other API change: `body` renamed to `filename` --- .../voicemessages/timeline/VoiceMessageMediaRepo.kt | 10 +++++----- .../voicemessages/timeline/VoiceMessagePlayer.kt | 12 ++++++------ .../voicemessages/timeline/VoiceMessagePresenter.kt | 2 +- .../timeline/DefaultVoiceMessageMediaRepoTest.kt | 2 +- .../timeline/DefaultVoiceMessagePlayerTest.kt | 2 +- .../timeline/VoiceMessagePresenterTest.kt | 4 ++-- .../libraries/matrix/api/media/MatrixMediaLoader.kt | 4 ++-- .../libraries/matrix/impl/media/RustMediaLoader.kt | 4 ++-- .../matrix/test/media/FakeMatrixMediaLoader.kt | 2 +- .../mediaviewer/api/viewer/MediaViewerPresenter.kt | 2 +- .../notifications/DefaultNotifiableEventResolver.kt | 2 +- .../push/impl/notifications/NotificationMediaRepo.kt | 8 ++++---- .../notifications/fake/FakeNotificationMediaRepo.kt | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessageMediaRepo.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessageMediaRepo.kt index d6bd4ea301..f1d8e5f987 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessageMediaRepo.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessageMediaRepo.kt @@ -35,12 +35,12 @@ interface VoiceMessageMediaRepo { * * @param mediaSource the media source of the voice message. * @param mimeType the mime type of the voice message. - * @param body the body of the voice message. + * @param filename the filename of the voice message. */ fun create( mediaSource: MediaSource, mimeType: String?, - body: String?, + filename: String?, ): VoiceMessageMediaRepo } @@ -61,7 +61,7 @@ class DefaultVoiceMessageMediaRepo @AssistedInject constructor( private val matrixMediaLoader: MatrixMediaLoader, @Assisted private val mediaSource: MediaSource, @Assisted("mimeType") private val mimeType: String?, - @Assisted("body") private val body: String?, + @Assisted("filename") private val filename: String?, ) : VoiceMessageMediaRepo { @ContributesBinding(RoomScope::class) @AssistedFactory @@ -69,7 +69,7 @@ class DefaultVoiceMessageMediaRepo @AssistedInject constructor( override fun create( mediaSource: MediaSource, @Assisted("mimeType") mimeType: String?, - @Assisted("body") body: String?, + @Assisted("filename") filename: String?, ): DefaultVoiceMessageMediaRepo } @@ -79,7 +79,7 @@ class DefaultVoiceMessageMediaRepo @AssistedInject constructor( else -> matrixMediaLoader.downloadMediaFile( source = mediaSource, mimeType = mimeType, - body = body, + filename = filename, ).mapCatching { it.use { mediaFile -> val dest = cachedFile.apply { parentFile?.mkdirs() } diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePlayer.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePlayer.kt index 42969b9754..aa339e3365 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePlayer.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePlayer.kt @@ -37,13 +37,13 @@ interface VoiceMessagePlayer { * @param eventId The eventId of the voice message event. * @param mediaSource The media source of the voice message. * @param mimeType The mime type of the voice message. - * @param body The body of the voice message. + * @param filename The filename of the voice message. */ fun create( eventId: EventId?, mediaSource: MediaSource, mimeType: String?, - body: String?, + filename: String?, ): VoiceMessagePlayer } @@ -113,7 +113,7 @@ class DefaultVoiceMessagePlayer( private val eventId: EventId?, mediaSource: MediaSource, mimeType: String?, - body: String?, + filename: String?, ) : VoiceMessagePlayer { @ContributesBinding(RoomScope::class) // Scoped types can't use @AssistedInject. class Factory @Inject constructor( @@ -124,21 +124,21 @@ class DefaultVoiceMessagePlayer( eventId: EventId?, mediaSource: MediaSource, mimeType: String?, - body: String?, + filename: String?, ): DefaultVoiceMessagePlayer = DefaultVoiceMessagePlayer( mediaPlayer = mediaPlayer, voiceMessageMediaRepoFactory = voiceMessageMediaRepoFactory, eventId = eventId, mediaSource = mediaSource, mimeType = mimeType, - body = body, + filename = filename, ) } private val repo = voiceMessageMediaRepoFactory.create( mediaSource = mediaSource, mimeType = mimeType, - body = body + filename = filename, ) private var internalState = MutableStateFlow( diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenter.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenter.kt index 155b47728a..8eb21e1528 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenter.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenter.kt @@ -59,7 +59,7 @@ class VoiceMessagePresenter @AssistedInject constructor( eventId = content.eventId, mediaSource = content.mediaSource, mimeType = content.mimeType, - body = content.caption, + filename = content.caption, ) private val play = mutableStateOf>(AsyncData.Uninitialized) diff --git a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessageMediaRepoTest.kt b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessageMediaRepoTest.kt index 462535d3c0..fcf1998097 100644 --- a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessageMediaRepoTest.kt +++ b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessageMediaRepoTest.kt @@ -137,7 +137,7 @@ private fun createDefaultVoiceMessageMediaRepo( json = null ), mimeType = MimeTypes.Ogg, - body = "someBody.ogg" + filename = "someBody.ogg" ) private const val MXC_URI = "mxc://matrix.org/1234567890abcdefg" diff --git a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessagePlayerTest.kt b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessagePlayerTest.kt index b5a11ba160..9a82b46776 100644 --- a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessagePlayerTest.kt +++ b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/DefaultVoiceMessagePlayerTest.kt @@ -279,7 +279,7 @@ private fun createDefaultVoiceMessagePlayer( json = null ), mimeType = MimeTypes.Ogg, - body = "someBody.ogg" + filename = "someBody.ogg" ) private const val MXC_URI = "mxc://matrix.org/1234567890abcdefg" diff --git a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenterTest.kt b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenterTest.kt index a4770539be..ceedf0948f 100644 --- a/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenterTest.kt +++ b/features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/voicemessages/timeline/VoiceMessagePresenterTest.kt @@ -226,14 +226,14 @@ fun TestScope.createVoiceMessagePresenter( analyticsService: AnalyticsService = FakeAnalyticsService(), content: TimelineItemVoiceContent = aTimelineItemVoiceContent(), ) = VoiceMessagePresenter( - voiceMessagePlayerFactory = { eventId, mediaSource, mimeType, body -> + voiceMessagePlayerFactory = { eventId, mediaSource, mimeType, filename -> DefaultVoiceMessagePlayer( mediaPlayer = mediaPlayer, voiceMessageMediaRepoFactory = { _, _, _ -> voiceMessageMediaRepo }, eventId = eventId, mediaSource = mediaSource, mimeType = mimeType, - body = body + filename = filename ) }, analyticsService = analyticsService, diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/MatrixMediaLoader.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/MatrixMediaLoader.kt index 06f6350b64..349e651cf1 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/MatrixMediaLoader.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/MatrixMediaLoader.kt @@ -25,14 +25,14 @@ interface MatrixMediaLoader { /** * @param source to fetch the data for. * @param mimeType: optional mime type. - * @param body: optional body which will be used to name the file. + * @param filename: optional String which will be used to name the file. * @param useCache: if true, the rust sdk will cache the media in its store. * @return a [Result] of [MediaFile] */ suspend fun downloadMediaFile( source: MediaSource, mimeType: String?, - body: String?, + filename: String?, useCache: Boolean = true, ): Result } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/RustMediaLoader.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/RustMediaLoader.kt index eb4d016b6c..9604d6af6d 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/RustMediaLoader.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/RustMediaLoader.kt @@ -63,7 +63,7 @@ class RustMediaLoader( override suspend fun downloadMediaFile( source: MediaSource, mimeType: String?, - body: String?, + filename: String?, useCache: Boolean, ): Result = withContext(mediaDispatcher) { @@ -71,7 +71,7 @@ class RustMediaLoader( source.toRustMediaSource().use { mediaSource -> val mediaFile = innerClient.getMediaFile( mediaSource = mediaSource, - body = body, + filename = filename, mimeType = mimeType?.takeIf { MimeTypes.hasSubtype(it) } ?: MimeTypes.OctetStream, useCache = useCache, tempDir = cacheDirectory.path, diff --git a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/media/FakeMatrixMediaLoader.kt b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/media/FakeMatrixMediaLoader.kt index 68bc3ed764..6a53d8658b 100644 --- a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/media/FakeMatrixMediaLoader.kt +++ b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/media/FakeMatrixMediaLoader.kt @@ -35,7 +35,7 @@ class FakeMatrixMediaLoader : MatrixMediaLoader { override suspend fun downloadMediaFile( source: MediaSource, mimeType: String?, - body: String?, + filename: String?, useCache: Boolean, ): Result = simulateLongTask { if (shouldFail) { diff --git a/libraries/mediaviewer/api/src/main/kotlin/io/element/android/libraries/mediaviewer/api/viewer/MediaViewerPresenter.kt b/libraries/mediaviewer/api/src/main/kotlin/io/element/android/libraries/mediaviewer/api/viewer/MediaViewerPresenter.kt index 3d51096dd3..3cef900040 100644 --- a/libraries/mediaviewer/api/src/main/kotlin/io/element/android/libraries/mediaviewer/api/viewer/MediaViewerPresenter.kt +++ b/libraries/mediaviewer/api/src/main/kotlin/io/element/android/libraries/mediaviewer/api/viewer/MediaViewerPresenter.kt @@ -92,7 +92,7 @@ class MediaViewerPresenter @AssistedInject constructor( mediaLoader.downloadMediaFile( source = inputs.mediaSource, mimeType = inputs.mediaInfo.mimeType, - body = inputs.mediaInfo.filename + filename = inputs.mediaInfo.filename ) .onSuccess { mediaFile.value = it diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotifiableEventResolver.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotifiableEventResolver.kt index 1d6e916124..2fb6186bd4 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotifiableEventResolver.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotifiableEventResolver.kt @@ -299,7 +299,7 @@ class DefaultNotifiableEventResolver @Inject constructor( .getMediaFile( mediaSource = messageType.source, mimeType = messageType.info?.mimetype, - body = messageType.filename, + filename = messageType.filename, ) is VideoMessageType -> null // Use the thumbnail here? else -> null diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationMediaRepo.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationMediaRepo.kt index f8818cf341..c53bbcd347 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationMediaRepo.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/notifications/NotificationMediaRepo.kt @@ -47,13 +47,13 @@ interface NotificationMediaRepo { * * @param mediaSource the media source of the media. * @param mimeType the mime type of the media. - * @param body optional body which will be used to name the file. + * @param filename optional String which will be used to name the file. * @return A [Result] holding either the media [File] from the cache directory or an [Exception]. */ suspend fun getMediaFile( mediaSource: MediaSource, mimeType: String?, - body: String?, + filename: String?, ): Result } @@ -75,7 +75,7 @@ class DefaultNotificationMediaRepo @AssistedInject constructor( override suspend fun getMediaFile( mediaSource: MediaSource, mimeType: String?, - body: String?, + filename: String?, ): Result { val cachedFile = mediaSource.cachedFile() return when { @@ -84,7 +84,7 @@ class DefaultNotificationMediaRepo @AssistedInject constructor( else -> matrixMediaLoader.downloadMediaFile( source = mediaSource, mimeType = mimeType, - body = body, + filename = filename, ).mapCatching { it.use { mediaFile -> val dest = cachedFile.apply { parentFile?.mkdirs() } diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeNotificationMediaRepo.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeNotificationMediaRepo.kt index 8ab7bf7d9c..68ce164284 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeNotificationMediaRepo.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeNotificationMediaRepo.kt @@ -15,7 +15,7 @@ class FakeNotificationMediaRepo : NotificationMediaRepo { override suspend fun getMediaFile( mediaSource: MediaSource, mimeType: String?, - body: String?, + filename: String?, ): Result { return Result.failure(IllegalStateException("Fake class")) }