PowerLevel: use new api exposed from rust which doesn't need to load members.

This commit is contained in:
ganfra 2023-07-18 15:10:44 +02:00
parent 7cefff8610
commit 669e62e462
10 changed files with 74 additions and 37 deletions

View file

@ -101,11 +101,11 @@ interface MatrixRoom : Closeable {
suspend fun inviteUserById(id: UserId): Result<Unit>
suspend fun canInvite(): Result<Boolean>
suspend fun canUserInvite(userId: UserId): Result<Boolean>
suspend fun canSendStateEvent(type: StateEventType): Result<Boolean>
suspend fun canUserSendState(userId: UserId, type: StateEventType): Result<Boolean>
suspend fun canSendEvent(type: MessageEventType): Result<Boolean>
suspend fun canUserSendMessage(userId: UserId, type: MessageEventType): Result<Boolean>
suspend fun updateAvatar(mimeType: String, data: ByteArray): Result<Unit>
@ -136,3 +136,5 @@ interface MatrixRoom : Closeable {
assetType: AssetType? = null,
): Result<Unit>
}

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.matrix.api.room.powerlevels
import io.element.android.libraries.matrix.api.room.MatrixRoom
import io.element.android.libraries.matrix.api.room.MessageEventType
import io.element.android.libraries.matrix.api.room.StateEventType
/**
* Shortcut for calling [MatrixRoom.canUserInvite] with out own user.
*/
suspend fun MatrixRoom.canInvite(): Result<Boolean> = canUserInvite(sessionId)
/**
* Shortcut for calling [MatrixRoom.canUserSendState] with out own user.
*/
suspend fun MatrixRoom.canSendState(type: StateEventType): Result<Boolean> = canUserSendState(sessionId, type)
/**
* Shortcut for calling [MatrixRoom.canUserSendMessage] with out own user.
*/
suspend fun MatrixRoom.canSendMessage(type: MessageEventType): Result<Boolean> = canUserSendMessage(sessionId, type)