mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
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:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user