mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 23:25:20 +03:00
restrict to share content without permissions
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
d76e833d74
commit
8b3d32584c
3 changed files with 33 additions and 6 deletions
|
@ -346,7 +346,9 @@ class ChatController(args: Bundle) :
|
|||
setTitle()
|
||||
|
||||
hasChatPermission =
|
||||
AttendeePermissionsUtil(currentConversation!!.permissions).hasChatPermission(conversationUser)
|
||||
AttendeePermissionsUtil(currentConversation!!.permissions).hasChatPermission(
|
||||
conversationUser
|
||||
)
|
||||
|
||||
try {
|
||||
setupMentionAutocomplete()
|
||||
|
@ -1458,6 +1460,12 @@ class ChatController(args: Bundle) :
|
|||
|
||||
private fun uploadFiles(files: MutableList<String>, isVoiceMessage: Boolean) {
|
||||
var metaData = ""
|
||||
|
||||
if (!hasChatPermission) {
|
||||
Log.e(TAG, "uploading file(s) is forbidden because of missing attendee permissions")
|
||||
return
|
||||
}
|
||||
|
||||
if (isVoiceMessage) {
|
||||
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.ConversationsListBottomDialog;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.AttendeePermissionsUtil;
|
||||
import com.nextcloud.talk.utils.ClosedInterfaceImpl;
|
||||
import com.nextcloud.talk.utils.ConductorRemapping;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
|
@ -359,7 +360,6 @@ public class ConversationsListController extends BaseController implements Searc
|
|||
|
||||
showShareToScreen = !showShareToScreen && hasActivityActionSendIntent();
|
||||
|
||||
|
||||
if (showShareToScreen) {
|
||||
hideSearchBar();
|
||||
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) {
|
||||
try {
|
||||
selectedConversation = ((ConversationItem) Objects.requireNonNull(adapter.getItem(position))).getModel();
|
||||
|
||||
if (selectedConversation != null && getActivity() != null) {
|
||||
boolean hasChatPermission =
|
||||
new AttendeePermissionsUtil(selectedConversation.permissions).hasChatPermission(currentUser);
|
||||
|
||||
if (showShareToScreen) {
|
||||
handleSharedData();
|
||||
showShareToScreen = false;
|
||||
if (hasChatPermission && !isReadOnlyConversation(selectedConversation)) {
|
||||
handleSharedData();
|
||||
showShareToScreen = false;
|
||||
} else {
|
||||
Toast.makeText(context, R.string.send_to_forbidden, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else if (forwardMessage) {
|
||||
openConversation(bundle.getString(BundleKeys.INSTANCE.getKEY_FORWARD_MSG_TEXT()));
|
||||
forwardMessage = false;
|
||||
if (hasChatPermission && !isReadOnlyConversation(selectedConversation)) {
|
||||
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 {
|
||||
openConversation();
|
||||
}
|
||||
|
@ -885,6 +897,11 @@ public class ConversationsListController extends BaseController implements Searc
|
|||
return true;
|
||||
}
|
||||
|
||||
private Boolean isReadOnlyConversation(Conversation conversation) {
|
||||
return conversation.conversationReadOnlyState ==
|
||||
Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY;
|
||||
}
|
||||
|
||||
private void handleSharedData() {
|
||||
collectDataFromIntent();
|
||||
if (!textToPaste.isEmpty()) {
|
||||
|
|
|
@ -392,6 +392,8 @@
|
|||
<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="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 -->
|
||||
<string name="nc_add_file">Add to conversation</string>
|
||||
|
|
Loading…
Reference in a new issue