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, currentConversation,
chatMessage, chatMessage,
conversationUser, conversationUser,
hasChatPermission,
ncApi!! ncApi!!
).show() ).show()
} }
@ -2519,6 +2520,7 @@ class ChatController(args: Bundle) :
conversationUser, conversationUser,
currentConversation, currentConversation,
isShowMessageDeletionButton(message), isShowMessageDeletionButton(message),
hasChatPermission,
ncApi!! ncApi!!
).show() ).show()
} }

View File

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

View File

@ -63,6 +63,7 @@ class ShowReactionsDialog(
private val currentConversation: Conversation?, private val currentConversation: Conversation?,
private val chatMessage: ChatMessage, private val chatMessage: ChatMessage,
private val userEntity: UserEntity?, private val userEntity: UserEntity?,
private val hasChatPermission: Boolean,
private val ncApi: NcApi private val ncApi: NcApi
) : BottomSheetDialog(activity), ReactionItemClickListener { ) : BottomSheetDialog(activity), ReactionItemClickListener {
@ -183,7 +184,7 @@ class ShowReactionsDialog(
} }
override fun onClick(reactionItem: ReactionItem) { 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!!) deleteReaction(chatMessage, reactionItem.reaction!!)
dismiss() dismiss()
} }