From 5409a95399783bed629e9402d9ef5a74ff988632 Mon Sep 17 00:00:00 2001
From: aydreeihn <adriane@enhancesoft.com>
Date: Fri, 3 Nov 2017 13:26:20 -0500
Subject: [PATCH] compare header's user/staff id to email's user/staff id to
 determine sender

---
 include/class.thread.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/class.thread.php b/include/class.thread.php
index 3911f714b..7ef4cd110 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -1190,9 +1190,17 @@ implements TemplateVariable {
             ) {
                 if (@$mid_info['userId']) {
                     $mailinfo['userId'] = $mid_info['userId'];
+
+                    $user = User::lookupByEmail($mailinfo['email']);
+                    if ($user && $mailinfo['userId'] != $user->getId())
+                      $mailinfo['userId'] = $user->getId();
                 }
                 elseif (@$mid_info['staffId']) {
                     $mailinfo['staffId'] = $mid_info['staffId'];
+
+                    $staffId = Staff::getIdByEmail($mailinfo['email']);
+                    if ($staffId && $mailinfo['staffId'] != $staffId)
+                      $mailinfo['staffId'] = $staffId;
                 }
 
                 // Capture the user type
-- 
GitLab