mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Moderation tweaks (#2548)
* Only allow admins to see the roles and permissions screen. * Hide the selection checkbox on Admins when changing roles. * Show an empty state for banned users. * Add separate actions for ban and remove. * Implement reset permissions and demote self alerts. * Add tests for resetting permissions and demoting self. * Add a warning when promoting someone to administrator.
This commit is contained in:
@@ -391,6 +391,24 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func resetPowerLevels() async -> Result<RoomPowerLevels, RoomProxyError> {
|
||||
do {
|
||||
return try await .success(room.resetPowerLevels())
|
||||
} catch {
|
||||
MXLog.error("Failed resetting the power levels: \(error)")
|
||||
return .failure(.failedSettingPermission)
|
||||
}
|
||||
}
|
||||
|
||||
func suggestedRole(for userID: String) async -> Result<RoomMemberRole, RoomProxyError> {
|
||||
do {
|
||||
return try await .success(room.suggestedRoleForUser(userId: userID))
|
||||
} catch {
|
||||
MXLog.error("Failed getting a user's role: \(error)")
|
||||
return .failure(.failedCheckingPermission)
|
||||
}
|
||||
}
|
||||
|
||||
func updatePowerLevelsForUsers(_ updates: [(userID: String, powerLevel: Int64)]) async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
let updates = updates.map { UserPowerLevelUpdate(userId: $0.userID, powerLevel: $0.powerLevel) }
|
||||
|
||||
@@ -117,6 +117,8 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func powerLevels() async -> Result<RoomPowerLevels, RoomProxyError>
|
||||
func applyPowerLevelChanges(_ changes: RoomPowerLevelChanges) async -> Result<Void, RoomProxyError>
|
||||
func resetPowerLevels() async -> Result<RoomPowerLevels, RoomProxyError>
|
||||
func suggestedRole(for userID: String) async -> Result<RoomMemberRole, RoomProxyError>
|
||||
func updatePowerLevelsForUsers(_ updates: [(userID: String, powerLevel: Int64)]) async -> Result<Void, RoomProxyError>
|
||||
func canUser(userID: String, sendStateEvent event: StateEventType) async -> Result<Bool, RoomProxyError>
|
||||
func canUserInvite(userID: String) async -> Result<Bool, RoomProxyError>
|
||||
|
||||
Reference in New Issue
Block a user