Differential D19033 Diff 45639 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | abstract class PhabricatorApplicationTransactionEditor | ||||
private $silent; | private $silent; | ||||
private $mustEncrypt; | private $mustEncrypt; | ||||
private $stampTemplates = array(); | private $stampTemplates = array(); | ||||
private $mailStamps = array(); | private $mailStamps = array(); | ||||
private $oldTo = array(); | private $oldTo = array(); | ||||
private $oldCC = array(); | private $oldCC = array(); | ||||
private $mailRemovedPHIDs = array(); | private $mailRemovedPHIDs = array(); | ||||
private $mailUnexpandablePHIDs = array(); | private $mailUnexpandablePHIDs = array(); | ||||
private $mailMutedPHIDs = array(); | |||||
private $transactionQueue = array(); | private $transactionQueue = array(); | ||||
const STORAGE_ENCODING_BINARY = 'binary'; | const STORAGE_ENCODING_BINARY = 'binary'; | ||||
/** | /** | ||||
* Get the class name for the application this editor is a part of. | * Get the class name for the application this editor is a part of. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 1,117 Lines • ▼ Show 20 Lines | if (!$this->getIsSilent()) { | ||||
$this->mailToPHIDs = $this->getMailTo($object); | $this->mailToPHIDs = $this->getMailTo($object); | ||||
$this->mailCCPHIDs = $this->getMailCC($object); | $this->mailCCPHIDs = $this->getMailCC($object); | ||||
$this->mailUnexpandablePHIDs = $this->newMailUnexpandablePHIDs($object); | $this->mailUnexpandablePHIDs = $this->newMailUnexpandablePHIDs($object); | ||||
// Add any recipients who were previously on the notification list | // Add any recipients who were previously on the notification list | ||||
// but were removed by this change. | // but were removed by this change. | ||||
$this->applyOldRecipientLists(); | $this->applyOldRecipientLists(); | ||||
if ($object instanceof PhabricatorSubscribableInterface) { | |||||
$this->mailMutedPHIDs = PhabricatorEdgeQuery::loadDestinationPHIDs( | |||||
$object->getPHID(), | |||||
PhabricatorMutedByEdgeType::EDGECONST); | |||||
} else { | |||||
$this->mailMutedPHIDs = array(); | |||||
} | |||||
$mail_xactions = $this->getTransactionsForMail($object, $xactions); | $mail_xactions = $this->getTransactionsForMail($object, $xactions); | ||||
$stamps = $this->newMailStamps($object, $xactions); | $stamps = $this->newMailStamps($object, $xactions); | ||||
foreach ($stamps as $stamp) { | foreach ($stamps as $stamp) { | ||||
$this->mailStamps[] = $stamp->toDictionary(); | $this->mailStamps[] = $stamp->toDictionary(); | ||||
} | } | ||||
} | } | ||||
if ($this->shouldPublishFeedStory($object, $xactions)) { | if ($this->shouldPublishFeedStory($object, $xactions)) { | ||||
▲ Show 20 Lines • Show All 1,435 Lines • ▼ Show 20 Lines | private function buildMailForTarget( | ||||
if (PhabricatorEnv::getEnvConfig('metamta.email-preferences')) { | if (PhabricatorEnv::getEnvConfig('metamta.email-preferences')) { | ||||
$this->addEmailPreferenceSectionToMailBody( | $this->addEmailPreferenceSectionToMailBody( | ||||
$body, | $body, | ||||
$object, | $object, | ||||
$mail_xactions); | $mail_xactions); | ||||
} | } | ||||
$muted_phids = $this->mailMutedPHIDs; | |||||
if (!is_array($muted_phids)) { | |||||
$muted_phids = array(); | |||||
} | |||||
->setSensitiveContent(false) | ->setSensitiveContent(false) | ||||
->setFrom($this->getActingAsPHID()) | ->setFrom($this->getActingAsPHID()) | ||||
->setSubjectPrefix($this->getMailSubjectPrefix()) | ->setSubjectPrefix($this->getMailSubjectPrefix()) | ||||
->setVarySubjectPrefix('['.$action.']') | ->setVarySubjectPrefix('['.$action.']') | ||||
->setThreadID($this->getMailThreadID($object), $this->getIsNewObject()) | ->setThreadID($this->getMailThreadID($object), $this->getIsNewObject()) | ||||
->setRelatedPHID($object->getPHID()) | ->setRelatedPHID($object->getPHID()) | ||||
->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs()) | ->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs()) | ||||
->setMutedPHIDs($muted_phids) | |||||
->setForceHeraldMailRecipientPHIDs($this->heraldForcedEmailPHIDs) | ->setForceHeraldMailRecipientPHIDs($this->heraldForcedEmailPHIDs) | ||||
->setMailTags($mail_tags) | ->setMailTags($mail_tags) | ||||
->setIsBulk(true) | ->setIsBulk(true) | ||||
->setBody($body->render()) | ->setBody($body->render()) | ||||
->setHTMLBody($body->renderHTML()); | ->setHTMLBody($body->renderHTML()); | ||||
foreach ($body->getAttachments() as $attachment) { | foreach ($body->getAttachments() as $attachment) { | ||||
$mail->addAttachment($attachment); | $mail->addAttachment($attachment); | ||||
▲ Show 20 Lines • Show All 500 Lines • ▼ Show 20 Lines | protected function publishFeedStory( | ||||
if (!$xactions) { | if (!$xactions) { | ||||
return; | return; | ||||
} | } | ||||
$related_phids = $this->feedRelatedPHIDs; | $related_phids = $this->feedRelatedPHIDs; | ||||
$subscribed_phids = $this->feedNotifyPHIDs; | $subscribed_phids = $this->feedNotifyPHIDs; | ||||
// Remove muted users from the subscription list so they don't get | |||||
// notifications, either. | |||||
$muted_phids = $this->mailMutedPHIDs; | |||||
if (!is_array($muted_phids)) { | |||||
$muted_phids = array(); | |||||
} | |||||
$subscribed_phids = array_fuse($subscribed_phids); | |||||
foreach ($muted_phids as $muted_phid) { | |||||
unset($subscribed_phids[$muted_phid]); | |||||
} | |||||
$subscribed_phids = array_values($subscribed_phids); | |||||
$story_type = $this->getFeedStoryType(); | $story_type = $this->getFeedStoryType(); | ||||
$story_data = $this->getFeedStoryData($object, $xactions); | $story_data = $this->getFeedStoryData($object, $xactions); | ||||
id(new PhabricatorFeedStoryPublisher()) | id(new PhabricatorFeedStoryPublisher()) | ||||
->setStoryType($story_type) | ->setStoryType($story_type) | ||||
->setStoryData($story_data) | ->setStoryData($story_data) | ||||
->setStoryTime(time()) | ->setStoryTime(time()) | ||||
->setStoryAuthorPHID($this->getActingAsPHID()) | ->setStoryAuthorPHID($this->getActingAsPHID()) | ||||
▲ Show 20 Lines • Show All 430 Lines • ▼ Show 20 Lines | return array( | ||||
'mailCCPHIDs', | 'mailCCPHIDs', | ||||
'feedNotifyPHIDs', | 'feedNotifyPHIDs', | ||||
'feedRelatedPHIDs', | 'feedRelatedPHIDs', | ||||
'feedShouldPublish', | 'feedShouldPublish', | ||||
'mailShouldSend', | 'mailShouldSend', | ||||
'mustEncrypt', | 'mustEncrypt', | ||||
'mailStamps', | 'mailStamps', | ||||
'mailUnexpandablePHIDs', | 'mailUnexpandablePHIDs', | ||||
'mailMutedPHIDs', | |||||
); | ); | ||||
} | } | ||||
/** | /** | ||||
* Apply encodings prior to storage. | * Apply encodings prior to storage. | ||||
* | * | ||||
* See @{method:getCustomWorkerStateEncoding}. | * See @{method:getCustomWorkerStateEncoding}. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 573 Lines • Show Last 20 Lines |