Merge pull request #4212 from element-hq/feature/fga/room_settings_security_privacy
Feature : room settings - security and privacy
This commit is contained in:
commit
346e3648e8
125 changed files with 3387 additions and 347 deletions
|
|
@ -8,6 +8,8 @@
|
|||
package io.element.android.libraries.matrix.api.createroom
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.room.join.JoinRule
|
||||
import io.element.android.libraries.matrix.api.roomdirectory.RoomVisibility
|
||||
import java.util.Optional
|
||||
|
||||
data class CreateRoomParameters(
|
||||
|
|
@ -19,6 +21,6 @@ data class CreateRoomParameters(
|
|||
val preset: RoomPreset,
|
||||
val invite: List<UserId>? = null,
|
||||
val avatar: String? = null,
|
||||
val joinRuleOverride: JoinRuleOverride = JoinRuleOverride.None,
|
||||
val joinRuleOverride: JoinRule? = null,
|
||||
val roomAliasName: Optional<String> = Optional.empty(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.createroom
|
||||
|
||||
/**
|
||||
* Rules to override the default room join rules.
|
||||
*/
|
||||
sealed interface JoinRuleOverride {
|
||||
data object Knock : JoinRuleOverride
|
||||
data object None : JoinRuleOverride
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023, 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
package io.element.android.libraries.matrix.api.createroom
|
||||
|
||||
enum class RoomVisibility {
|
||||
PUBLIC,
|
||||
PRIVATE,
|
||||
}
|
||||
|
|
@ -24,10 +24,13 @@ import io.element.android.libraries.matrix.api.media.MediaUploadHandler
|
|||
import io.element.android.libraries.matrix.api.media.VideoInfo
|
||||
import io.element.android.libraries.matrix.api.poll.PollKind
|
||||
import io.element.android.libraries.matrix.api.room.draft.ComposerDraft
|
||||
import io.element.android.libraries.matrix.api.room.history.RoomHistoryVisibility
|
||||
import io.element.android.libraries.matrix.api.room.join.JoinRule
|
||||
import io.element.android.libraries.matrix.api.room.knock.KnockRequest
|
||||
import io.element.android.libraries.matrix.api.room.location.AssetType
|
||||
import io.element.android.libraries.matrix.api.room.powerlevels.MatrixRoomPowerLevels
|
||||
import io.element.android.libraries.matrix.api.room.powerlevels.UserRoleChange
|
||||
import io.element.android.libraries.matrix.api.roomdirectory.RoomVisibility
|
||||
import io.element.android.libraries.matrix.api.timeline.ReceiptType
|
||||
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventOrTransactionId
|
||||
|
|
@ -43,7 +46,7 @@ interface MatrixRoom : Closeable {
|
|||
val sessionId: SessionId
|
||||
val roomId: RoomId
|
||||
val displayName: String
|
||||
val alias: RoomAlias?
|
||||
val canonicalAlias: RoomAlias?
|
||||
val alternativeAliases: List<RoomAlias>
|
||||
val topic: String?
|
||||
val avatarUrl: String?
|
||||
|
|
@ -403,4 +406,60 @@ interface MatrixRoom : Closeable {
|
|||
suspend fun withdrawVerificationAndResend(userIds: List<UserId>, sendHandle: SendHandle): Result<Unit>
|
||||
|
||||
override fun close() = destroy()
|
||||
|
||||
/**
|
||||
* Update the canonical alias of the room.
|
||||
*
|
||||
* Note that publishing the alias in the room directory is done separately.
|
||||
*/
|
||||
suspend fun updateCanonicalAlias(
|
||||
canonicalAlias: RoomAlias?,
|
||||
alternativeAliases: List<RoomAlias>
|
||||
): Result<Unit>
|
||||
|
||||
/**
|
||||
* Update the room's visibility in the room directory.
|
||||
*/
|
||||
suspend fun updateRoomVisibility(roomVisibility: RoomVisibility): Result<Unit>
|
||||
|
||||
/**
|
||||
* Update room history visibility for this room.
|
||||
*/
|
||||
suspend fun updateHistoryVisibility(historyVisibility: RoomHistoryVisibility): Result<Unit>
|
||||
|
||||
/**
|
||||
* Returns the visibility for this room in the room directory.
|
||||
* If the room is not published, the result will be [RoomVisibility.Private].
|
||||
*/
|
||||
suspend fun getRoomVisibility(): Result<RoomVisibility>
|
||||
|
||||
/**
|
||||
* Publish a new room alias for this room in the room directory.
|
||||
*
|
||||
* Returns:
|
||||
* - `true` if the room alias didn't exist and it's now published.
|
||||
* - `false` if the room alias was already present so it couldn't be
|
||||
* published.
|
||||
*/
|
||||
suspend fun publishRoomAliasInRoomDirectory(roomAlias: RoomAlias): Result<Boolean>
|
||||
|
||||
/**
|
||||
* Remove an existing room alias for this room in the room directory.
|
||||
*
|
||||
* Returns:
|
||||
* - `true` if the room alias was present and it's now removed from the
|
||||
* room directory.
|
||||
* - `false` if the room alias didn't exist so it couldn't be removed.
|
||||
*/
|
||||
suspend fun removeRoomAliasFromRoomDirectory(roomAlias: RoomAlias): Result<Boolean>
|
||||
|
||||
/**
|
||||
* Enable End-to-end encryption in this room.
|
||||
*/
|
||||
suspend fun enableEncryption(): Result<Unit>
|
||||
|
||||
/**
|
||||
* Update the join rule for this room.
|
||||
*/
|
||||
suspend fun updateJoinRule(joinRule: JoinRule): Result<Unit>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import io.element.android.libraries.matrix.api.core.EventId
|
|||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.room.history.RoomHistoryVisibility
|
||||
import io.element.android.libraries.matrix.api.room.join.JoinRule
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
|
@ -71,6 +72,7 @@ data class MatrixRoomInfo(
|
|||
val heroes: ImmutableList<MatrixUser>,
|
||||
val pinnedEventIds: ImmutableList<EventId>,
|
||||
val creator: UserId?,
|
||||
val historyVisibility: RoomHistoryVisibility,
|
||||
) {
|
||||
val aliases: List<RoomAlias>
|
||||
get() = listOfNotNull(canonicalAlias) + alternativeAliases
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ fun MatrixRoom.matches(roomIdOrAlias: RoomIdOrAlias): Boolean {
|
|||
roomIdOrAlias.roomId == roomId
|
||||
}
|
||||
is RoomIdOrAlias.Alias -> {
|
||||
roomIdOrAlias.roomAlias == alias || roomIdOrAlias.roomAlias in alternativeAliases
|
||||
roomIdOrAlias.roomAlias == canonicalAlias || roomIdOrAlias.roomAlias in alternativeAliases
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.room.history
|
||||
|
||||
sealed interface RoomHistoryVisibility {
|
||||
/**
|
||||
* Previous events are accessible to newly joined members from the point
|
||||
* they were invited onwards.
|
||||
*
|
||||
* Events stop being accessible when the member's state changes to
|
||||
* something other than *invite* or *join*.
|
||||
*/
|
||||
data object Invited : RoomHistoryVisibility
|
||||
|
||||
/**
|
||||
* Previous events are accessible to newly joined members from the point
|
||||
* they joined the room onwards.
|
||||
* Events stop being accessible when the member's state changes to
|
||||
* something other than *join*.
|
||||
*/
|
||||
data object Joined : RoomHistoryVisibility
|
||||
|
||||
/**
|
||||
* Previous events are always accessible to newly joined members.
|
||||
*
|
||||
* All events in the room are accessible, even those sent when the member
|
||||
* was not a part of the room.
|
||||
*/
|
||||
data object Shared : RoomHistoryVisibility
|
||||
|
||||
/**
|
||||
* All events while this is the `HistoryVisibility` value may be shared by
|
||||
* any participating homeserver with anyone, regardless of whether they
|
||||
* have ever joined the room.
|
||||
*/
|
||||
data object WorldReadable : RoomHistoryVisibility
|
||||
|
||||
/**
|
||||
* A custom visibility value.
|
||||
*/
|
||||
data class Custom(val value: String) : RoomHistoryVisibility
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.api.roomdirectory
|
||||
|
||||
/**
|
||||
* Enum class representing the visibility of a room in the room directory.
|
||||
*/
|
||||
sealed interface RoomVisibility {
|
||||
/**
|
||||
* Indicates that the room will be shown in the published room list.
|
||||
*/
|
||||
data object Public : RoomVisibility
|
||||
|
||||
/**
|
||||
* Indicates that the room will not be shown in the published room list.
|
||||
*/
|
||||
data object Private : RoomVisibility
|
||||
|
||||
/**
|
||||
* A custom value that's not present in the spec.
|
||||
*/
|
||||
data class Custom(val value: String) : RoomVisibility
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue