Adopt the lastest SDK APIs and refactor how we deal with user permissions.

This patch introduces a new RoomPowerLevelsProxy and its associated mock and adopts newer Rust APIs to make working with user power levels and permissions easier.
This commit is contained in:
Stefan Ceriu
2025-06-20 14:20:01 +03:00
committed by Stefan Ceriu
parent 96e5ed06f5
commit f522e15dac
25 changed files with 1863 additions and 1660 deletions
@@ -152,20 +152,11 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
// MARK: - Power Levels
func powerLevels() async -> Result<RoomPowerLevels, RoomProxyError>
func powerLevels() async -> Result<RoomPowerLevelsProxyProtocol, RoomProxyError>
func applyPowerLevelChanges(_ changes: RoomPowerLevelChanges) async -> Result<Void, RoomProxyError>
func resetPowerLevels() async -> Result<RoomPowerLevels, RoomProxyError>
func resetPowerLevels() async -> Result<Void, 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, sendMessage messageType: MessageLikeEventType) async -> Result<Bool, RoomProxyError>
func canUser(userID: String, sendStateEvent event: StateEventType) async -> Result<Bool, RoomProxyError>
func canUserInvite(userID: String) async -> Result<Bool, RoomProxyError>
func canUserRedactOther(userID: String) async -> Result<Bool, RoomProxyError>
func canUserRedactOwn(userID: String) async -> Result<Bool, RoomProxyError>
func canUserKick(userID: String) async -> Result<Bool, RoomProxyError>
func canUserBan(userID: String) async -> Result<Bool, RoomProxyError>
func canUserTriggerRoomNotification(userID: String) async -> Result<Bool, RoomProxyError>
func canUserPinOrUnpin(userID: String) async -> Result<Bool, RoomProxyError>
// MARK: - Moderation
@@ -175,9 +166,7 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
// MARK: - Element Call
func canUserJoinCall(userID: String) async -> Result<Bool, RoomProxyError>
func elementCallWidgetDriver(deviceID: String) -> ElementCallWidgetDriverProtocol
func sendCallNotificationIfNeeded() async -> Result<Void, RoomProxyError>
// MARK: - Permalinks