Security and privacy part 2 (#3637)

* handling the history visibility flag

* better logic to handle visibility

* better handling of the visibility options state

* added some copies, and the public room directory

visibility state

* completed the UI

added also the preview tests

* improved the handling of the directory visibility

* added the space users case

and improved handling of the access -> vsibility reaction. Also added a simple error handling for the public directory toggle

* added the edit room address view

but is missing its full implementation

* implement the UI for the edit room address screen

* implemented error checking

when editing the address

* updated preview tests and improved code

* typo fix

* Fix various issues after rebasing.

* Fix build errors and broken snapshot tests

* Adopt latest room privacy and canonical alias setting APIs

* Add support for creating and editing the room's alias.

* Add support for saving room privacy setting changes.

* Fix room alias screen snapshot tests following recent changes.

---------

Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
This commit is contained in:
Mauro
2025-01-15 10:50:08 +01:00
committed by GitHub
parent cfb01d61a0
commit e3ad925285
61 changed files with 2216 additions and 136 deletions
@@ -190,6 +190,16 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
}
}
func enableEncryption() async -> Result<Void, RoomProxyError> {
do {
try await room.enableEncryption()
return .success(())
} catch {
MXLog.error("Failed enabling encryption with error: \(error)")
return .failure(.sdkError(error))
}
}
func redact(_ eventID: String) async -> Result<Void, RoomProxyError> {
do {
try await room.redact(eventId: eventID, reason: nil)
@@ -359,6 +369,79 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
}
}
// MARK: - Privacy settings
func updateJoinRule(_ rule: JoinRule) async -> Result<Void, RoomProxyError> {
do {
try await room.updateJoinRules(newRule: rule)
return .success(())
} catch {
MXLog.error("Failed updating join rule with error: \(error)")
return .failure(.sdkError(error))
}
}
func updateHistoryVisibility(_ visibility: RoomHistoryVisibility) async -> Result<Void, RoomProxyError> {
do {
try await room.updateHistoryVisibility(visibility: visibility)
return .success(())
} catch {
MXLog.error("Failed updating history visibility with error: \(error)")
return .failure(.sdkError(error))
}
}
func isVisibleInRoomDirectory() async -> Result<Bool, RoomProxyError> {
do {
return try await .success(room.getRoomVisibility() == .public)
} catch {
MXLog.error("Failed checking if room is visible in room directory with error: \(error)")
return .failure(.sdkError(error))
}
}
func updateRoomDirectoryVisibility(_ visibility: RoomVisibility) async -> Result<Void, RoomProxyError> {
do {
try await room.updateRoomVisibility(visibility: visibility)
return .success(())
} catch {
MXLog.error("Failed updating room directory visibility with error: \(error)")
return .failure(.sdkError(error))
}
}
// MARK: - Canonical Alias
func updateCanonicalAlias(_ alias: String?, altAliases: [String]) async -> Result<Void, RoomProxyError> {
do {
try await room.updateCanonicalAlias(alias: alias, altAliases: altAliases)
return .success(())
} catch {
MXLog.error("Failed updating canonical alias with error: \(error)")
return .failure(.sdkError(error))
}
}
func publishRoomAliasInRoomDirectory(_ alias: String) async -> Result<Bool, RoomProxyError> {
do {
let result = try await room.publishRoomAliasInRoomDirectory(alias: alias)
return .success(result)
} catch {
MXLog.error("Failed publishing the room's alias in the room directory with error: \(error)")
return .failure(.sdkError(error))
}
}
func removeRoomAliasFromRoomDirectory(_ alias: String) async -> Result<Bool, RoomProxyError> {
do {
let result = try await room.removeRoomAliasFromRoomDirectory(alias: alias)
return .success(result)
} catch {
MXLog.error("Failed removing the room's alias in the room directory with error: \(error)")
return .failure(.sdkError(error))
}
}
// MARK: - Room flags
func flagAsUnread(_ isUnread: Bool) async -> Result<Void, RoomProxyError> {
@@ -66,6 +66,7 @@ struct RoomInfoProxy: BaseRoomInfoProxyProtocol {
var unreadMentionsCount: UInt { UInt(roomInfo.numUnreadMentions) }
var pinnedEventIDs: Set<String> { Set(roomInfo.pinnedEventIds) }
var joinRule: JoinRule? { roomInfo.joinRule }
var historyVisibility: RoomHistoryVisibility { roomInfo.historyVisibility }
}
struct RoomPreviewInfoProxy: BaseRoomInfoProxyProtocol {
@@ -79,6 +79,8 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
func messageFilteredTimeline(allowedMessageTypes: [RoomMessageEventMessageType]) async -> Result<TimelineProxyProtocol, RoomProxyError>
func enableEncryption() async -> Result<Void, RoomProxyError>
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
@@ -110,6 +112,21 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
func withdrawVerificationAndResend(userIDs: [String], sendHandle: SendHandleProxy) async -> Result<Void, RoomProxyError>
// MARK: - Privacy settings
func updateJoinRule(_ rule: JoinRule) async -> Result<Void, RoomProxyError>
func updateHistoryVisibility(_ visibility: RoomHistoryVisibility) async -> Result<Void, RoomProxyError>
func isVisibleInRoomDirectory() async -> Result<Bool, RoomProxyError>
func updateRoomDirectoryVisibility(_ visibility: RoomVisibility) async -> Result<Void, RoomProxyError>
// MARK: - Canonical Alias
func updateCanonicalAlias(_ alias: String?, altAliases: [String]) async -> Result<Void, RoomProxyError>
func publishRoomAliasInRoomDirectory(_ alias: String) async -> Result<Bool, RoomProxyError>
func removeRoomAliasFromRoomDirectory(_ alias: String) async -> Result<Bool, RoomProxyError>
// MARK: - Room Flags
func flagAsUnread(_ isUnread: Bool) async -> Result<Void, RoomProxyError>