Skip to content
Snippets Groups Projects
Commit b9baa2cc authored by Jared Hancock's avatar Jared Hancock
Browse files

collabs: Skip activity notice if collabs included in Cc header

parent e8cedfd6
No related branches found
No related tags found
No related merge requests found
......@@ -380,6 +380,33 @@ Class ThreadEntry {
return $references;
}
/**
* Retrieve a list of all the recients of this message if the message
* was received via email.
*
* Returns:
* (array<RFC_822>) list of recipients parsed with the Mail/RFC822
* address parsing utility. Returns an empty array if the message was
* not received via email.
*/
function getAllEmailRecipients() {
$headers = self::getEmailHeaderArray();
$recipients = array();
if (!$headers)
return $recipients;
foreach (array('To', 'Cc') as $H) {
if (!isset($headers[$H]))
continue;
if (!($all = Mail_Parse::parseAddressList($headers[$H])))
continue;
$recipients = array_merge($recipients, $all);
}
return $recipients;
}
function getUIDFromEmailReference($ref) {
$info = unpack('Vtid/Vuid',
......
......@@ -1102,15 +1102,24 @@ class Ticket {
return;
//Who posted the entry?
$uid = 0;
$skip = array();
if ($entry instanceof Message) {
$poster = $entry->getUser();
// Skip the person who sent in the message
$uid = $entry->getUserId();
$skip[$entry->getUserId()] = 1;
// Skip all the other recipients of the message
foreach ($entry->getEmailAllRecipients() as $R) {
foreach ($recipients as $R2) {
if ($R2->getEmail() == ($R->mailbox.'@'.$R->hostname)) {
$skip[$R2->getUserId()] = true;
break;
}
}
}
} else {
$poster = $entry->getStaff();
// Skip the ticket owner
$uid = $this->getUserId();
$skip[$this->getUserId()] = 1;
}
$vars = array_merge($vars, array(
......@@ -1125,7 +1134,10 @@ class Ticket {
$options = array('inreplyto' => $entry->getEmailMessageId(),
'thread' => $entry);
foreach ($recipients as $recipient) {
if ($uid == $recipient->getUserId()) continue;
// Skip folks who have already been included on this part of
// the conversation
if (isset($skip[$recipient->getUserId()]))
continue;
$notice = $this->replaceVars($msg, array('recipient' => $recipient));
$email->send($recipient, $notice['subj'], $notice['body'], $attachments,
$options);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment