Skip to content

Commit

Permalink
Add as CC a customer who was in CC and replied to the conversation - #…
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Dec 17, 2023
1 parent 1578046 commit 6d917f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ public static function typeToName($type)
}

/**
* Get emails which are excluded from CC and BCC.
* Get emails which should be excluded from CC and BCC.
*/
public function getExcludeArray($mailbox = null)
{
Expand Down
19 changes: 18 additions & 1 deletion app/Http/Controllers/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,24 @@ public function view(Request $request, $id)
$template = 'conversations/create';
}

// CC.
$exclude_array = $conversation->getExcludeArray($mailbox);
$cc = $conversation->getCcArray($exclude_array);

// If last reply came from customer who was mentioned in CC before,
// we need to add this customer as CC.
// https://github.com/freescout-helpdesk/freescout/issues/3613
foreach ($threads as $thread) {
if ($thread->isUserMessage() && !$thread->isDraft()) {
break;
}
if ($thread->isCustomerMessage()) {
if ($thread->customer_id != $conversation->customer_id) {
$cc[] = $thread->from;
}
break;
}
}

// Get data for creating a phone conversation.
$name = [];
Expand Down Expand Up @@ -352,7 +369,7 @@ public function view(Request $request, $id)
'to' => $new_conv_to,
'to_customers' => $to_customers,
'prev_conversations' => $prev_conversations,
'cc' => $conversation->getCcArray($exclude_array),
'cc' => $cc,
'bcc' => [], //$conversation->getBccArray($exclude_array),
// Data for creating a phone conversation.
'name' => $name,
Expand Down

0 comments on commit 6d917f8

Please sign in to comment.