Merge pull request #2653 from element-hq/feature/bma/copyPermalink
Copy permalink
This commit is contained in:
@@ -328,5 +328,12 @@ interface MatrixRoom : Closeable {
|
||||
*/
|
||||
fun getWidgetDriver(widgetSettings: MatrixWidgetSettings): Result<MatrixWidgetDriver>
|
||||
|
||||
/**
|
||||
* Get the permalink for the provided [eventId].
|
||||
* @param eventId The event id to get the permalink for.
|
||||
* @return The permalink, or a failure.
|
||||
*/
|
||||
suspend fun getPermalinkFor(eventId: EventId): Result<String>
|
||||
|
||||
override fun close() = destroy()
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -84,6 +84,7 @@ class FakeMatrixRoom(
|
||||
override val activeMemberCount: Long = 234L,
|
||||
val notificationSettingsService: NotificationSettingsService = FakeNotificationSettingsService(),
|
||||
private val matrixTimeline: MatrixTimeline = FakeMatrixTimeline(),
|
||||
private var permalinkResult: () -> Result<String> = { Result.success("link") },
|
||||
canRedactOwn: Boolean = false,
|
||||
canRedactOther: Boolean = false,
|
||||
) : MatrixRoom {
|
||||
@@ -273,6 +274,10 @@ class FakeMatrixRoom(
|
||||
return cancelSendResult
|
||||
}
|
||||
|
||||
override suspend fun getPermalinkFor(eventId: EventId): Result<String> {
|
||||
return permalinkResult()
|
||||
}
|
||||
|
||||
override suspend fun editMessage(
|
||||
originalEventId: EventId?,
|
||||
transactionId: TransactionId?,
|
||||
|
||||
Reference in New Issue
Block a user