mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:01:40 +00:00
Merge branch 'develop' into feature/fga/safer_callback_flows
This commit is contained in:
+5
-4
@@ -95,9 +95,9 @@ object PermalinkParser {
|
||||
return if (signUrl.isNullOrEmpty().not() && email.isNullOrEmpty().not()) {
|
||||
try {
|
||||
val signValidUri = Uri.parse(signUrl)
|
||||
val identityServerHost = signValidUri.authority ?: throw IllegalArgumentException()
|
||||
val token = signValidUri.getQueryParameter("token") ?: throw IllegalArgumentException()
|
||||
val privateKey = signValidUri.getQueryParameter("private_key") ?: throw IllegalArgumentException()
|
||||
val identityServerHost = signValidUri.authority ?: throw IllegalArgumentException("missing `authority`")
|
||||
val token = signValidUri.getQueryParameter("token") ?: throw IllegalArgumentException("missing `token`")
|
||||
val privateKey = signValidUri.getQueryParameter("private_key") ?: throw IllegalArgumentException("missing `private_key`")
|
||||
PermalinkData.RoomEmailInviteLink(
|
||||
roomId = identifier,
|
||||
email = email!!,
|
||||
@@ -137,7 +137,8 @@ object PermalinkParser {
|
||||
.parameterList
|
||||
.filter {
|
||||
it.mParameter == "via"
|
||||
}.map {
|
||||
}
|
||||
.map {
|
||||
URLDecoder.decode(it.mValue, "UTF-8")
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -105,6 +105,8 @@ interface MatrixRoom : Closeable {
|
||||
|
||||
suspend fun canUserInvite(userId: UserId): Result<Boolean>
|
||||
|
||||
suspend fun canUserRedact(userId: UserId): Result<Boolean>
|
||||
|
||||
suspend fun canUserSendState(userId: UserId, type: StateEventType): Result<Boolean>
|
||||
|
||||
suspend fun canUserSendMessage(userId: UserId, type: MessageEventType): Result<Boolean>
|
||||
|
||||
+6
@@ -34,3 +34,9 @@ suspend fun MatrixRoom.canSendState(type: StateEventType): Result<Boolean> = can
|
||||
* Shortcut for calling [MatrixRoom.canUserSendMessage] with our own user.
|
||||
*/
|
||||
suspend fun MatrixRoom.canSendMessage(type: MessageEventType): Result<Boolean> = canUserSendMessage(sessionId, type)
|
||||
|
||||
/**
|
||||
* Shortcut for calling [MatrixRoom.canUserRedact] with our own user.
|
||||
*/
|
||||
suspend fun MatrixRoom.canRedact(): Result<Boolean> = canUserRedact(sessionId)
|
||||
|
||||
|
||||
+4
-2
@@ -147,7 +147,8 @@ class RustMatrixClient constructor(
|
||||
if (syncState == SyncState.Running) {
|
||||
onSlidingSyncUpdate()
|
||||
}
|
||||
}.launchIn(sessionCoroutineScope)
|
||||
}
|
||||
.launchIn(sessionCoroutineScope)
|
||||
}
|
||||
|
||||
override suspend fun getRoom(roomId: RoomId): MatrixRoom? = withContext(sessionDispatcher) {
|
||||
@@ -227,7 +228,8 @@ class RustMatrixClient constructor(
|
||||
roomSummaryDataSource.allRooms()
|
||||
.filter { roomSummaries ->
|
||||
roomSummaries.map { it.identifier() }.contains(roomId.value)
|
||||
}.first()
|
||||
}
|
||||
.first()
|
||||
}
|
||||
roomId
|
||||
}
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ class RustMatrixAuthenticationService @Inject constructor(
|
||||
client.restoreSession(sessionData.toSession())
|
||||
createMatrixClient(client)
|
||||
} else {
|
||||
throw IllegalStateException("No session to restore with id $sessionId")
|
||||
error("No session to restore with id $sessionId")
|
||||
}
|
||||
}.mapFailure { failure ->
|
||||
failure.mapClientException()
|
||||
|
||||
+6
@@ -250,6 +250,12 @@ class RustMatrixRoom(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun canUserRedact(userId: UserId): Result<Boolean> {
|
||||
return runCatching {
|
||||
innerRoom.canUserRedact(userId.value)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun canUserSendState(userId: UserId, type: StateEventType): Result<Boolean> {
|
||||
return runCatching {
|
||||
innerRoom.canUserSendState(userId.value, type.map())
|
||||
|
||||
+2
-1
@@ -64,7 +64,8 @@ internal class RustRoomSummaryDataSource(
|
||||
.map { it.toRoomSummaryDataSourceLoadingState() }
|
||||
.onEach {
|
||||
allRoomsLoadingState.value = it
|
||||
}.launchIn(this)
|
||||
}
|
||||
.launchIn(this)
|
||||
|
||||
launch {
|
||||
// Wait until running, as invites is only available after that
|
||||
|
||||
+2
-1
@@ -118,7 +118,8 @@ class RustMatrixTimeline(
|
||||
innerRoom.backPaginationStatusFlow()
|
||||
.onEach {
|
||||
postPaginationStatus(it)
|
||||
}.launchIn(this)
|
||||
}
|
||||
.launchIn(this)
|
||||
|
||||
taskHandleBag += fetchMembers().getOrNull()
|
||||
}.invokeOnCompletion {
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import java.util.Date
|
||||
|
||||
class TimelineEncryptedHistoryPostProcessorTest {
|
||||
|
||||
private val defaultLastLoginTimestamp = Date(1689061264L)
|
||||
private val defaultLastLoginTimestamp = Date(1_689_061_264L)
|
||||
|
||||
@Test
|
||||
fun `given an unencrypted room, nothing is done`() {
|
||||
|
||||
+6
@@ -56,6 +56,7 @@ class FakeMatrixRoom(
|
||||
override val joinedMemberCount: Long = 123L,
|
||||
override val activeMemberCount: Long = 234L,
|
||||
private val matrixTimeline: MatrixTimeline = FakeMatrixTimeline(),
|
||||
canRedact: Boolean = false,
|
||||
) : MatrixRoom {
|
||||
|
||||
private var ignoreResult: Result<Unit> = Result.success(Unit)
|
||||
@@ -66,6 +67,7 @@ class FakeMatrixRoom(
|
||||
private var joinRoomResult = Result.success(Unit)
|
||||
private var inviteUserResult = Result.success(Unit)
|
||||
private var canInviteResult = Result.success(true)
|
||||
private var canRedactResult = Result.success(canRedact)
|
||||
private val canSendStateResults = mutableMapOf<StateEventType, Result<Boolean>>()
|
||||
private val canSendEventResults = mutableMapOf<MessageEventType, Result<Boolean>>()
|
||||
private var sendMediaResult = Result.success(Unit)
|
||||
@@ -207,6 +209,10 @@ class FakeMatrixRoom(
|
||||
return canInviteResult
|
||||
}
|
||||
|
||||
override suspend fun canUserRedact(userId: UserId): Result<Boolean> {
|
||||
return canRedactResult
|
||||
}
|
||||
|
||||
override suspend fun canUserSendState(userId: UserId, type: StateEventType): Result<Boolean> {
|
||||
return canSendStateResults[type] ?: Result.failure(IllegalStateException("No fake answer"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user