Skip to content

Commit

Permalink
Fix showing only assigned to the user tickets - closes #3843
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-helpdesk committed Mar 2, 2024
1 parent 100b406 commit 911e157
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,12 @@ public static function getQueryByFolder($folder, $user_id)
if ($user->id == $user_id
&& $user->hasManageMailboxPermission($folder->mailbox_id, Mailbox::ACCESS_PERM_ASSIGNED)
) {
$query_conversations->where('user_id', '=', $user_id);
if ($folder->type != Folder::TYPE_DRAFTS) {
$query_conversations->where('user_id', '=', $user_id);
} else {
$query_conversations->where('user_id', '=', $user_id)
->orWhere('created_by_user_id', '=', $user_id);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ public function ajax(Request $request)
$new = true;
if (!$response['msg'] && !empty($request->conversation_id)) {
$conversation = Conversation::find($request->conversation_id);
if ($conversation && !$user->can('view', $conversation)) {
if ($conversation && !$user->can('view', $conversation) && !$user->hasManageMailboxPermission($request->mailbox_id, Mailbox::ACCESS_PERM_ASSIGNED)) {
$response['msg'] = __('Not enough permissions');
} else {
$new = false;
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/ConversationPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function viewCached(User $user, Conversation $conversation)
if ($conversation->mailbox->users_cached->contains($user)) {
// Maybe user can see only assigned conversations.
if (!\Eventy::filter('conversation.is_user_assignee', $conversation->user_id == $user->id, $conversation, $user->id)
&& $user->hasManageMailboxPermission($conversation->mailbox_id, Mailbox::ACCESS_PERM_ASSIGNED)
&& !$user->hasManageMailboxPermission($conversation->mailbox_id, Mailbox::ACCESS_PERM_ASSIGNED)
) {
return false;
} else {
Expand Down

0 comments on commit 911e157

Please sign in to comment.