diff --git a/include/class.thread.php b/include/class.thread.php index b6fc9b5f15504d779dc7619d0e4a6fc384ab8bd2..ecfae52fd5087da5fa1b92427985f9313681e66d 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -312,6 +312,7 @@ class Thread extends VerySimpleModel { 'reply_to' => $entry, 'recipients' => $mailinfo['recipients'], 'to-email-id' => $mailinfo['to-email-id'], + 'autorespond' => !isset($mailinfo['passive']), ); // XXX: Is this necessary? @@ -1178,40 +1179,19 @@ implements TemplateVariable { // ThreadEntry was positively identified return $t; } + } - // Try to determine if it's a reply to a tagged email. - // (Deprecated) - $ref = null; - if (strpos($mid, '+')) { - list($left, $right) = explode('@',$mid); - list($left, $ref) = explode('+', $left); - $mid = "$left@$right"; - } - $entries = ThreadEntry::objects() - ->filter(array('email_info__mid' => $mid)) - ->order_by(false); - foreach ($entries as $t) { - // Capture the first match thread item - if (!$thread) - $thread = $t; - // We found a match - see if we can ID the user. - // XXX: Check access of ref is enough? - if ($ref && ($uid = $t->getUIDFromEmailReference($ref))) { - if ($ref[0] =='s') //staff - $mailinfo['staffId'] = $uid; - else // user or collaborator. - $mailinfo['userId'] = $uid; - - // Best possible case — found the thread and the - // user - return $t; - } - } + // Passive threading - listen mode + $entry = ThreadEntry::objects() + ->filter(array( + 'email_info__mid__in' => array_map( + function ($a) { return "<$a>"; }, + $possibles))) + ->first(); + if ($entry) { + $mailinfo['passive'] = true; + return $entry; } - // Second best case — found a thread but couldn't identify the - // user from the header. Return the first thread entry matched - if ($thread) - return $thread; // Search for ticket by the [#123456] in the subject line // This is the last resort - emails must match to avoid message diff --git a/include/class.ticket.php b/include/class.ticket.php index d126259da8b1dbb6604b8ab085c3b5ee066395bb..a8ccd95859e271f4d8f460e064f0c25e9ddd3b3e 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2336,6 +2336,8 @@ implements RestrictedAccess, Threadable { : true; if ($autorespond && $message->isBounceOrAutoReply()) $autorespond = false; + elseif ($autorespond && isset($vars['autorespond'])) + $autorespond = $vars['autorespond']; $this->onMessage($message, ($autorespond && $alerts)); //must be called b4 sending alerts to staff.