Disable the composer when you don't have the power to post. (#4076)

This commit is contained in:
Doug
2025-04-29 10:12:20 +01:00
committed by GitHub
parent 41b18cfd52
commit 58b982a8f8
15 changed files with 150 additions and 19 deletions
@@ -559,6 +559,15 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
}
}
func canUser(userID: String, sendMessage messageType: MessageLikeEventType) async -> Result<Bool, RoomProxyError> {
do {
return try await .success(room.canUserSendMessage(userId: userID, message: messageType))
} catch {
MXLog.error("Failed checking if the user can send message with error: \(error)")
return .failure(.sdkError(error))
}
}
func canUser(userID: String, sendStateEvent event: StateEventType) async -> Result<Bool, RoomProxyError> {
do {
return try await .success(room.canUserSendState(userId: userID, stateEvent: event))
@@ -150,6 +150,7 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
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, 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>