diff --git a/app/Conversation.php b/app/Conversation.php index 722ca84a2..2bca11cf0 100644 --- a/app/Conversation.php +++ b/app/Conversation.php @@ -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) { diff --git a/app/Http/Controllers/ConversationsController.php b/app/Http/Controllers/ConversationsController.php index f06ca6479..417e1d010 100755 --- a/app/Http/Controllers/ConversationsController.php +++ b/app/Http/Controllers/ConversationsController.php @@ -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 = []; @@ -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,