Add action to copy permalink #2650

This commit is contained in:
Benoit Marty 2024-04-03 15:36:39 +02:00
parent a65e073aca
commit bf068f4f25
10 changed files with 86 additions and 0 deletions

View file

@ -16,6 +16,7 @@
package io.element.android.libraries.matrix.impl.room
import io.element.android.appconfig.MatrixConfiguration
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
import io.element.android.libraries.core.coroutine.childScope
import io.element.android.libraries.matrix.api.core.EventId
@ -711,6 +712,19 @@ class RustMatrixRoom(
)
}
override suspend fun getPermalinkFor(eventId: EventId): Result<String> {
// FIXME Use the SDK API once https://github.com/matrix-org/matrix-rust-sdk/issues/3259 has been done
// Now use a simple builder
return runCatching {
buildString {
append(MatrixConfiguration.MATRIX_TO_PERMALINK_BASE_URL)
append(roomId.value)
append("/")
append(eventId.value)
}
}
}
private fun sendAttachment(files: List<File>, handle: () -> SendAttachmentJoinHandle): Result<MediaUploadHandler> {
return runCatching {
MediaUploadHandlerImpl(files, handle())