From 9d09973c8f71ded7de53c31144871a0663aa7347 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 26 May 2014 13:31:45 -0500
Subject: [PATCH] mail: No auto responses for auto-reply mails

This requires extra processing in the mail backend, perhaps through a
plugin, which would detect and flag a message as an auto-reply. Auto-replies
are added to the ticket thread, but have the automated responses disabled.
---
 include/class.ticket.php | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index c3f492469..271a7b427 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1596,7 +1596,9 @@ class Ticket {
         if(!$alerts) return $message; //Our work is done...
 
         // Do not auto-respond to bounces and other auto-replies
-        $autorespond = isset($vars['flags']) ? !$vars['flags']['bounce'] : true;
+        $autorespond = isset($vars['flags'])
+            ? !$vars['flags']['bounce'] && !$vars['flags']['auto-reply']
+            : true;
         if ($autorespond && $message->isAutoReply())
             $autorespond = false;
 
@@ -1843,9 +1845,12 @@ class Ticket {
         if(!($note=$this->getThread()->addNote($vars, $errors)))
             return null;
 
-        if (isset($vars['flags']) && $vars['flags']['bounce'])
-            // No alerts for bounce emails
-            $alert = false;
+        $alert = $alert && (
+            isset($vars['flags'])
+            // No alerts for bounce and auto-reply emails
+            ? !$vars['flags']['bounce'] && !$vars['flags']['auto-reply']
+            : true
+        );
 
         // Get assigned staff just in case the ticket is closed.
         $assignee = $this->getStaff();
-- 
GitLab