Skip to content

Commit

Permalink
Do not change customer when CCed email replies to a conversation - cl…
Browse files Browse the repository at this point in the history
…oses #3551
  • Loading branch information
freescout-help-desk committed Dec 2, 2023
1 parent 2fb0c29 commit 9b024bd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/Console/Commands/FetchEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ public function saveCustomerThread($mailbox, $message_id, $prev_thread, $from, $
$now = date('Y-m-d H:i:s');
}
$conv_cc = $cc;
$prev_conv_cc = $conv_cc;
// Customers are created before with email and name
$customer = Customer::create($from);
Expand All @@ -911,6 +912,7 @@ public function saveCustomerThread($mailbox, $message_id, $prev_thread, $from, $
// If reply came from another customer: change customer, add original as CC.
// If FreeScout will not change the customer, the reply will be shown
// as coming from the original customer (not the real sender) and cause confusion.
// Below after events are fired we roll customer back.
if ($conversation->customer_id != $customer->id) {
$prev_customer_id = $conversation->customer_id;
$prev_customer_email = $conversation->customer_email;
Expand Down Expand Up @@ -1043,8 +1045,16 @@ public function saveCustomerThread($mailbox, $message_id, $prev_thread, $from, $
}
// Conversation customer changed
// if ($prev_customer_id) {
// event(new ConversationCustomerChanged($conversation, $prev_customer_id, $prev_customer_email, null, $customer));
// }
// Return original customer back.
if ($prev_customer_id) {
event(new ConversationCustomerChanged($conversation, $prev_customer_id, $prev_customer_email, null, $customer));
$conversation->customer_id = $prev_customer_id;
$conversation->customer_email = $prev_customer_email;
$conversation->setCc(array_merge($prev_conv_cc, array_diff($to, $mailbox->getEmails())));
$conversation->save();
}
return $thread;
Expand Down

0 comments on commit 9b024bd

Please sign in to comment.