mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 08:15:02 +00:00
feat(share): share user permalinks via to.healthchat.ch
Mention pills keep the matrix.to wire format other clients expect.
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ class UserProfileNodeHelper(
|
||||
context: Context,
|
||||
permalinkBuilder: PermalinkBuilder,
|
||||
) {
|
||||
val permalinkResult = permalinkBuilder.permalinkForUser(userId)
|
||||
val permalinkResult = permalinkBuilder.sharePermalinkForUser(userId)
|
||||
permalinkResult.onSuccess { permalink ->
|
||||
context.startSharePlainTextIntent(
|
||||
activityResultLauncher = null,
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class DefaultInviteFriendsUseCase(
|
||||
private val permalinkBuilder: PermalinkBuilder,
|
||||
) : InviteFriendsUseCase {
|
||||
override fun execute(activity: Activity) {
|
||||
val permalinkResult = permalinkBuilder.permalinkForUser(matrixClient.sessionId)
|
||||
val permalinkResult = permalinkBuilder.sharePermalinkForUser(matrixClient.sessionId)
|
||||
permalinkResult.fold(
|
||||
onSuccess = { permalink ->
|
||||
val appName = buildMeta.applicationName
|
||||
|
||||
+10
@@ -14,6 +14,16 @@ import io.element.android.libraries.matrix.api.core.UserId
|
||||
interface PermalinkBuilder {
|
||||
fun permalinkForUser(userId: UserId): Result<String>
|
||||
fun permalinkForRoomAlias(roomAlias: RoomAlias): Result<String>
|
||||
|
||||
/**
|
||||
* Permalink meant to be shared outside of Matrix, for instance through the system share sheet.
|
||||
* It points to the HealthChat matrix.to deployment, so that recipients who do not have the app
|
||||
* yet are offered HealthChat rather than Element.
|
||||
*
|
||||
* Links embedded in events (mention pills, replies, …) must keep using [permalinkForUser]:
|
||||
* matrix.to is the format other Matrix clients expect on the wire.
|
||||
*/
|
||||
fun sharePermalinkForUser(userId: UserId): Result<String>
|
||||
}
|
||||
|
||||
sealed class PermalinkBuilderError : Throwable() {
|
||||
|
||||
+11
@@ -10,6 +10,8 @@ package io.element.android.libraries.matrix.impl.permalink
|
||||
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import io.element.android.appconfig.MatrixConfiguration
|
||||
import io.element.android.libraries.core.extensions.replacePrefix
|
||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||
import io.element.android.libraries.matrix.api.core.MatrixPatterns
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
@@ -38,4 +40,13 @@ class DefaultPermalinkBuilder : PermalinkBuilder {
|
||||
matrixToRoomAliasPermalink(roomAlias.value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun sharePermalinkForUser(userId: UserId): Result<String> {
|
||||
return permalinkForUser(userId).map { permalink ->
|
||||
permalink.replacePrefix(
|
||||
MatrixConfiguration.MATRIX_TO_PERMALINK_BASE_URL,
|
||||
MatrixConfiguration.HEALTHCHAT_TO_PERMALINK_BASE_URL,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -16,6 +16,7 @@ import io.element.android.tests.testutils.lambda.lambdaError
|
||||
class FakePermalinkBuilder(
|
||||
private val permalinkForUserLambda: (UserId) -> Result<String> = { lambdaError() },
|
||||
private val permalinkForRoomAliasLambda: (RoomAlias) -> Result<String> = { lambdaError() },
|
||||
private val sharePermalinkForUserLambda: (UserId) -> Result<String> = { lambdaError() },
|
||||
) : PermalinkBuilder {
|
||||
override fun permalinkForUser(userId: UserId): Result<String> {
|
||||
return permalinkForUserLambda(userId)
|
||||
@@ -24,4 +25,8 @@ class FakePermalinkBuilder(
|
||||
override fun permalinkForRoomAlias(roomAlias: RoomAlias): Result<String> {
|
||||
return permalinkForRoomAliasLambda(roomAlias)
|
||||
}
|
||||
|
||||
override fun sharePermalinkForUser(userId: UserId): Result<String> {
|
||||
return sharePermalinkForUserLambda(userId)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user