Skip to content

Commit 18629f7

Browse files
committed
feat(permissions): Update reaction permissions handling and add corresponding error message
Signed-off-by: Florian Ludwig <[email protected]>
1 parent 1a873f9 commit 18629f7

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,7 +3976,7 @@ class ChatActivity :
39763976

39773977
override fun onClickReaction(chatMessage: ChatMessage, emoji: String) {
39783978
if (!participantPermissions.hasReactPermission()) {
3979-
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
3979+
Snackbar.make(binding.root, R.string.reaction_forbidden, Snackbar.LENGTH_LONG).show()
39803980
return
39813981
}
39823982
VibrationUtils.vibrateShort(context)
@@ -3997,7 +3997,7 @@ class ChatActivity :
39973997
roomToken,
39983998
chatMessage,
39993999
conversationUser,
4000-
participantPermissions.hasChatPermission(),
4000+
participantPermissions.hasReactPermission(),
40014001
ncApi
40024002
).show()
40034003
}

app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ShowReactionsDialog(
4747
private val roomToken: String,
4848
private val chatMessage: ChatMessage,
4949
private val user: User?,
50-
private val hasChatPermission: Boolean,
50+
private val hasReactPermission: Boolean,
5151
private val ncApi: NcApi
5252
) : BottomSheetDialog(activity),
5353
ReactionItemClickListener {
@@ -185,7 +185,7 @@ class ShowReactionsDialog(
185185
}
186186

187187
override fun onClick(reactionItem: ReactionItem) {
188-
if (hasChatPermission && reactionItem.reactionVoter.actorId?.equals(user?.userId) == true) {
188+
if (hasReactPermission && reactionItem.reactionVoter.actorId?.equals(user?.userId) == true) {
189189
deleteReaction(chatMessage, reactionItem.reaction!!)
190190
adapter?.list?.remove(reactionItem)
191191
dismiss()

app/src/main/java/com/nextcloud/talk/utils/ParticipantPermissions.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,8 @@ class ParticipantPermissions(
7676
// Server supports separate react permission - check REACT bit
7777
return hasReactPermission
7878
}
79-
if (CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.CHAT_PERMISSION)) {
80-
// Older server without react-permission capability - fall back to CHAT permission
81-
// as that's what controlled reactions before the split
82-
return hasChatPermission
83-
}
84-
// if capability is not available then the spreed version doesn't support to restrict this
85-
return true
79+
// Older server without react-permission capability - fall back to chat permission
80+
return hasChatPermission()
8681
}
8782

8883
companion object {

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ How to translate with transifex:
550550
<string name="read_storage_no_permission">Sharing files from storage is not possible without permissions</string>
551551
<string name="open_in_files_app">Open in Files app</string>
552552
<string name="send_to_forbidden">You are not allowed to share content to this chat</string>
553+
<string name="reaction_forbidden">You are not allowed to add or remove reactions in this conversation</string>
553554

554555
<string name="typing_is_typing">is typing …</string>
555556
<string name="typing_are_typing">are typing …</string>

0 commit comments

Comments
 (0)