mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Code review
This commit is contained in:
parent
f2ab0987cc
commit
819e7c49b0
7 changed files with 29 additions and 13 deletions
|
@ -123,6 +123,15 @@ interface IdentityService {
|
|||
*/
|
||||
suspend fun getShareStatus(threePids: List<ThreePid>): Map<ThreePid, SharedState>
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
|
|
@ -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<String> {
|
||||
return UrlQuerySanitizer(this)
|
||||
.parameterList
|
||||
|
|
|
@ -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<Sign3pidInvitationTask.Params,
|
|||
}
|
||||
|
||||
internal class DefaultSign3pidInvitationTask @Inject constructor(
|
||||
@AuthenticatedIdentity
|
||||
@Unauthenticated
|
||||
private val okHttpClient: Lazy<OkHttpClient>,
|
||||
private val retrofitFactory: RetrofitFactory,
|
||||
@UserId private val userId: String
|
||||
|
|
|
@ -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<String>) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -238,7 +238,6 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted private val ini
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun handleJoinRoom() = withState { state ->
|
||||
|
|
|
@ -3544,9 +3544,12 @@
|
|||
<string name="help_space_members">Help space members find private rooms</string>
|
||||
<string name="to_help_space_members_find_and_join">To help space members find and join a private room, go to that room’s settings by tapping on the avatar.</string>
|
||||
|
||||
<!-- %s will be replaced by an email at runtime -->
|
||||
<string name="this_invite_to_this_room_was_sent">This invite to this room was sent to %s which is not associated with your account</string>
|
||||
<!-- %s will be replaced by an email at runtime -->
|
||||
<string name="this_invite_to_this_space_was_sent">This invite to this space was sent to %s which is not associated with your account</string>
|
||||
<!-- this is the part of link_this_email_with_your_account that should be a link-->
|
||||
|
||||
<string name="link_this_email_settings_link">Link this email with your account</string>
|
||||
<string name="link_this_email_with_your_account">Link this email with your account in Settings to receive invites directly in Element.</string>
|
||||
<!-- %s will be replaced by the value of link_this_email_settings_link and styled as a link -->
|
||||
<string name="link_this_email_with_your_account">%s in Settings to receive invites directly in Element.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue