diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt index 15ca748e4e..1485ec478b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt @@ -123,6 +123,15 @@ interface IdentityService { */ suspend fun getShareStatus(threePids: List): Map + /** + * When one performs a 3pid invite and the third party identifier is unknown, the home server + * will store the invitation in the Identity server and store some information in the room state membership event. + * The email invite will contains the token and secret that can be used to claim the stored invitation + * + * To aid clients who may not be able to perform crypto themselves, + * the identity server offers some crypto functionality to help in accepting invitations. + * This is less secure than the client doing it itself, but may be useful where this isn't possible. + */ suspend fun sign3pidInvitation(identiyServer: String, token: String, secret: String) : SignInvitationResult fun addListener(listener: IdentityServiceListener) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt index 99cca715b8..0108bbf7e4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt @@ -67,12 +67,7 @@ object PermalinkParser { MatrixPatterns.isGroupId(identifier) -> PermalinkData.GroupLink(groupId = identifier) MatrixPatterns.isRoomId(identifier) -> { // Can't rely on built in parsing because it's messing around the signurl - val paramList = fragment.substringAfter("?").split('&').mapNotNull { - val splitNameValue = it.split("=") - if (splitNameValue.size == 2) { - Pair(splitNameValue[0], URLDecoder.decode(splitNameValue[1], "UTF-8")) - } else null - } + val paramList = safeExtractParams(fragment) val signUrl = paramList.firstOrNull { it.first == "signurl" }?.second val email = paramList.firstOrNull { it.first == "email" }?.second if (signUrl.isNullOrEmpty().not() && email.isNullOrEmpty().not()) { @@ -118,6 +113,13 @@ object PermalinkParser { } } + private fun safeExtractParams(fragment: String) = fragment.substringAfter("?").split('&').mapNotNull { + val splitNameValue = it.split("=") + if (splitNameValue.size == 2) { + Pair(splitNameValue[0], URLDecoder.decode(splitNameValue[1], "UTF-8")) + } else null + } + private fun String.getViaParameters(): List { return UrlQuerySanitizer(this) .parameterList diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/Sign3pidInvitationTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/Sign3pidInvitationTask.kt index a8bb1d475b..11ec51e505 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/Sign3pidInvitationTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/Sign3pidInvitationTask.kt @@ -18,7 +18,7 @@ package org.matrix.android.sdk.internal.session.identity import dagger.Lazy import okhttp3.OkHttpClient -import org.matrix.android.sdk.internal.di.AuthenticatedIdentity +import org.matrix.android.sdk.internal.di.Unauthenticated import org.matrix.android.sdk.internal.di.UserId import org.matrix.android.sdk.internal.network.RetrofitFactory import org.matrix.android.sdk.internal.session.identity.model.SignInvitationResult @@ -34,7 +34,7 @@ internal interface Sign3pidInvitationTask : Task, private val retrofitFactory: RetrofitFactory, @UserId private val userId: String diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt index c3bcef60f2..f69949cbb6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt @@ -126,7 +126,7 @@ internal class DefaultRoomService @Inject constructor( override suspend fun joinRoom(roomId: String, reason: String?, thirdPartySigned: SignInvitationResult) { - joinRoomTask.execute(JoinRoomTask.Params(roomIdOrAlias, reason, thirdPartySigned = thirdPartySigned)) + joinRoomTask.execute(JoinRoomTask.Params(roomId, reason, thirdPartySigned = thirdPartySigned)) } override suspend fun markAllAsRead(roomIds: List) { diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt index 07c4c65a28..99667f620a 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt @@ -126,7 +126,10 @@ class RoomPreviewNoPreviewFragment @Inject constructor( } +"\n" span { - text = getString(R.string.link_this_email_with_your_account) + text = getString( + R.string.link_this_email_with_your_account, + getString(R.string.link_this_email_settings_link) + ) .toSpannable() .tappableMatchingText(getString(R.string.link_this_email_settings_link), object : ClickableSpan() { override fun onClick(widget: View) { diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt index 94b7a315c3..a559b0554d 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt @@ -238,7 +238,6 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted private val ini } } } - } private fun handleJoinRoom() = withState { state -> diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 691289f5b4..47a55442b4 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3544,9 +3544,12 @@ Help space members find private rooms To help space members find and join a private room, go to that room’s settings by tapping on the avatar. + This invite to this room was sent to %s which is not associated with your account + This invite to this space was sent to %s which is not associated with your account - + Link this email with your account - Link this email with your account in Settings to receive invites directly in Element. + + %s in Settings to receive invites directly in Element.