don't allow to post/delete reaction without permission

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-05-10 17:07:56 +02:00
parent bae65ebbe9
commit 36383dfcc6
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
3 changed files with 9 additions and 4 deletions

View File

@ -2492,6 +2492,7 @@ class ChatController(args: Bundle) :
currentConversation,
chatMessage,
conversationUser,
hasChatPermission,
ncApi!!
).show()
}
@ -2519,6 +2520,7 @@ class ChatController(args: Bundle) :
conversationUser,
currentConversation,
isShowMessageDeletionButton(message),
hasChatPermission,
ncApi!!
).show()
}

View File

@ -58,6 +58,7 @@ class MessageActionsDialog(
private val user: UserEntity?,
private val currentConversation: Conversation?,
private val showMessageDeletionButton: Boolean,
private val hasChatPermission: Boolean,
private val ncApi: NcApi
) : BottomSheetDialog(chatController.activity!!, R.style.BottomSheetDialogThemeNoFloating) {
@ -71,7 +72,7 @@ class MessageActionsDialog(
setContentView(dialogMessageActionsBinding.root)
window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
initEmojiBar()
initEmojiBar(hasChatPermission)
initMenuItemCopy(!message.isDeleted)
initMenuReplyToMessage(message.replyable)
initMenuReplyPrivately(
@ -160,8 +161,9 @@ class MessageActionsDialog(
}
}
private fun initEmojiBar() {
if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "reactions") &&
private fun initEmojiBar(hasChatPermission: Boolean) {
if (hasChatPermission &&
CapabilitiesUtil.hasSpreedFeatureCapability(user, "reactions") &&
Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY !=
currentConversation?.conversationReadOnlyState &&
isReactableMessageType(message)

View File

@ -63,6 +63,7 @@ class ShowReactionsDialog(
private val currentConversation: Conversation?,
private val chatMessage: ChatMessage,
private val userEntity: UserEntity?,
private val hasChatPermission: Boolean,
private val ncApi: NcApi
) : BottomSheetDialog(activity), ReactionItemClickListener {
@ -183,7 +184,7 @@ class ShowReactionsDialog(
}
override fun onClick(reactionItem: ReactionItem) {
if (reactionItem.reactionVoter.actorId?.equals(userEntity?.userId) == true) {
if (hasChatPermission && reactionItem.reactionVoter.actorId?.equals(userEntity?.userId) == true) {
deleteReaction(chatMessage, reactionItem.reaction!!)
dismiss()
}