mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 20:49:36 +01:00
restrict to share content without permissions
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
d76e833d74
commit
8b3d32584c
@ -346,7 +346,9 @@ class ChatController(args: Bundle) :
|
|||||||
setTitle()
|
setTitle()
|
||||||
|
|
||||||
hasChatPermission =
|
hasChatPermission =
|
||||||
AttendeePermissionsUtil(currentConversation!!.permissions).hasChatPermission(conversationUser)
|
AttendeePermissionsUtil(currentConversation!!.permissions).hasChatPermission(
|
||||||
|
conversationUser
|
||||||
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setupMentionAutocomplete()
|
setupMentionAutocomplete()
|
||||||
@ -1458,6 +1460,12 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
private fun uploadFiles(files: MutableList<String>, isVoiceMessage: Boolean) {
|
private fun uploadFiles(files: MutableList<String>, isVoiceMessage: Boolean) {
|
||||||
var metaData = ""
|
var metaData = ""
|
||||||
|
|
||||||
|
if (!hasChatPermission) {
|
||||||
|
Log.e(TAG, "uploading file(s) is forbidden because of missing attendee permissions")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (isVoiceMessage) {
|
if (isVoiceMessage) {
|
||||||
metaData = VOICE_MESSAGE_META_DATA
|
metaData = VOICE_MESSAGE_META_DATA
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@ import com.nextcloud.talk.models.json.statuses.StatusesOverall;
|
|||||||
import com.nextcloud.talk.ui.dialog.ChooseAccountDialogFragment;
|
import com.nextcloud.talk.ui.dialog.ChooseAccountDialogFragment;
|
||||||
import com.nextcloud.talk.ui.dialog.ConversationsListBottomDialog;
|
import com.nextcloud.talk.ui.dialog.ConversationsListBottomDialog;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
|
import com.nextcloud.talk.utils.AttendeePermissionsUtil;
|
||||||
import com.nextcloud.talk.utils.ClosedInterfaceImpl;
|
import com.nextcloud.talk.utils.ClosedInterfaceImpl;
|
||||||
import com.nextcloud.talk.utils.ConductorRemapping;
|
import com.nextcloud.talk.utils.ConductorRemapping;
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
@ -359,7 +360,6 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
|
|
||||||
showShareToScreen = !showShareToScreen && hasActivityActionSendIntent();
|
showShareToScreen = !showShareToScreen && hasActivityActionSendIntent();
|
||||||
|
|
||||||
|
|
||||||
if (showShareToScreen) {
|
if (showShareToScreen) {
|
||||||
hideSearchBar();
|
hideSearchBar();
|
||||||
getActionBar().setTitle(R.string.send_to_three_dots);
|
getActionBar().setTitle(R.string.send_to_three_dots);
|
||||||
@ -867,13 +867,25 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
public boolean onItemClick(View view, int position) {
|
public boolean onItemClick(View view, int position) {
|
||||||
try {
|
try {
|
||||||
selectedConversation = ((ConversationItem) Objects.requireNonNull(adapter.getItem(position))).getModel();
|
selectedConversation = ((ConversationItem) Objects.requireNonNull(adapter.getItem(position))).getModel();
|
||||||
|
|
||||||
if (selectedConversation != null && getActivity() != null) {
|
if (selectedConversation != null && getActivity() != null) {
|
||||||
|
boolean hasChatPermission =
|
||||||
|
new AttendeePermissionsUtil(selectedConversation.permissions).hasChatPermission(currentUser);
|
||||||
|
|
||||||
if (showShareToScreen) {
|
if (showShareToScreen) {
|
||||||
handleSharedData();
|
if (hasChatPermission && !isReadOnlyConversation(selectedConversation)) {
|
||||||
showShareToScreen = false;
|
handleSharedData();
|
||||||
|
showShareToScreen = false;
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, R.string.send_to_forbidden, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
} else if (forwardMessage) {
|
} else if (forwardMessage) {
|
||||||
openConversation(bundle.getString(BundleKeys.INSTANCE.getKEY_FORWARD_MSG_TEXT()));
|
if (hasChatPermission && !isReadOnlyConversation(selectedConversation)) {
|
||||||
forwardMessage = false;
|
openConversation(bundle.getString(BundleKeys.INSTANCE.getKEY_FORWARD_MSG_TEXT()));
|
||||||
|
forwardMessage = false;
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, R.string.send_to_forbidden, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
openConversation();
|
openConversation();
|
||||||
}
|
}
|
||||||
@ -885,6 +897,11 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Boolean isReadOnlyConversation(Conversation conversation) {
|
||||||
|
return conversation.conversationReadOnlyState ==
|
||||||
|
Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleSharedData() {
|
private void handleSharedData() {
|
||||||
collectDataFromIntent();
|
collectDataFromIntent();
|
||||||
if (!textToPaste.isEmpty()) {
|
if (!textToPaste.isEmpty()) {
|
||||||
|
@ -392,6 +392,8 @@
|
|||||||
<string name="send_to_three_dots">Send to …</string>
|
<string name="send_to_three_dots">Send to …</string>
|
||||||
<string name="read_storage_no_permission">Sharing files from storage is not possible without permissions</string>
|
<string name="read_storage_no_permission">Sharing files from storage is not possible without permissions</string>
|
||||||
<string name="open_in_files_app">Open in Files app</string>
|
<string name="open_in_files_app">Open in Files app</string>
|
||||||
|
<string name="send_to_forbidden">You are not allowed to share content to this chat</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Upload -->
|
<!-- Upload -->
|
||||||
<string name="nc_add_file">Add to conversation</string>
|
<string name="nc_add_file">Add to conversation</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user