From a7286221ed8a2ac72237ed119e1f940f7096b4e0 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 3 Sep 2013 20:28:13 +0000
Subject: [PATCH] Fixup message-id tracking for piped emails

---
 include/api.tickets.php     | 5 +++--
 include/class.mailparse.php | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/api.tickets.php b/include/api.tickets.php
index 59f6c6f5a..afad901d5 100644
--- a/include/api.tickets.php
+++ b/include/api.tickets.php
@@ -20,7 +20,8 @@ class TicketApiController extends ApiController {
 
         if(!strcasecmp($format, 'email'))
             $supported = array_merge($supported, array('header', 'mid',
-                'emailId', 'ticketId', 'reply-to', 'reply-to-name'));
+                'emailId', 'ticketId', 'reply-to', 'reply-to-name',
+                'in-reply-to', 'references'));
 
         return $supported;
     }
@@ -115,7 +116,7 @@ class TicketApiController extends ApiController {
 
         if (($thread = ThreadEntry::lookupByEmailHeaders($data))
                 && $thread->postEmail($data)) {
-            return true;
+            return $thread->getTicket();
         }
         return $this->createTicket($data);
     }
diff --git a/include/class.mailparse.php b/include/class.mailparse.php
index d224b9fe7..f0ae3842e 100644
--- a/include/class.mailparse.php
+++ b/include/class.mailparse.php
@@ -341,6 +341,9 @@ class EmailDataParser {
         $data['priorityId'] = $parser->getPriority();
         $data['emailId'] = $emailId;
 
+        $data['in-reply-to'] = $parser->struct->headers['in-reply-to'];
+        $data['references'] = $parser->struct->headers['references'];
+
         if ($replyto = $parser->getReplyTo()) {
             $replyto = $replyto[0];
             $data['reply-to'] = $replyto->mailbox.'@'.$replyto->host;
-- 
GitLab