Differential D11329 Diff 27202 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
| Show All 23 Lines | abstract class PhabricatorApplicationTransactionEditor | ||||
| private $unmentionablePHIDMap = array(); | private $unmentionablePHIDMap = array(); | ||||
| private $isPreview; | private $isPreview; | ||||
| private $isHeraldEditor; | private $isHeraldEditor; | ||||
| private $isInverseEdgeEditor; | private $isInverseEdgeEditor; | ||||
| private $actingAsPHID; | private $actingAsPHID; | ||||
| private $disableEmail; | private $disableEmail; | ||||
| protected $emailData; | |||||
| /** | /** | ||||
| * 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. | ||||
| * | * | ||||
| * Uninstalling the application will disable the editor. | * Uninstalling the application will disable the editor. | ||||
| * | * | ||||
| * @return string Editor's application class name. | * @return string Editor's application class name. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 749 Lines • ▼ Show 20 Lines | final public function applyTransactions( | ||||
| // in various transaction phases). | // in various transaction phases). | ||||
| $this->loadSubscribers($object); | $this->loadSubscribers($object); | ||||
| $this->loadHandles($xactions); | $this->loadHandles($xactions); | ||||
| $mail = null; | $mail = null; | ||||
| if (!$this->getDisableEmail()) { | if (!$this->getDisableEmail()) { | ||||
| if ($this->shouldSendMail($object, $xactions)) { | if ($this->shouldSendMail($object, $xactions)) { | ||||
| // FIXME: fix the $mail recipient list for the feed | |||||
| $mail = $this->sendMail($object, $xactions); | $mail = $this->sendMail($object, $xactions); | ||||
| } | } | ||||
| } | } | ||||
| if ($this->supportsSearch()) { | if ($this->supportsSearch()) { | ||||
| id(new PhabricatorSearchIndexer()) | id(new PhabricatorSearchIndexer()) | ||||
| ->queueDocumentForIndexing( | ->queueDocumentForIndexing( | ||||
| $object->getPHID(), | $object->getPHID(), | ||||
| ▲ Show 20 Lines • Show All 1,096 Lines • ▼ Show 20 Lines | /* -( Sending Mail )------------------------------------------------------- */ | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function shouldSendMail( | protected function shouldSendMail( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| // FIXME: Make abstract? | |||||
| protected function getTransactionEmailWorkerClass() { | |||||
| throw new Exception('This function needs to be implemented to be able to render Email'); | |||||
| } | |||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function sendMail( | protected function sendMail( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| // Check if any of the transactions are visible. If we don't have any | // Check if any of the transactions are visible. If we don't have any | ||||
epriestley: This is a good catch, I missed it! | |||||
| // visible transactions, don't send the mail. | // visible transactions, don't send the mail. | ||||
| $any_visible = false; | $any_visible = false; | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| if (!$xaction->shouldHideForMail($xactions)) { | if (!$xaction->shouldHideForMail($xactions)) { | ||||
| $any_visible = true; | $any_visible = true; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (!$any_visible) { | if (!$any_visible) { | ||||
| return; | return; | ||||
| } | } | ||||
| $herald_xscript = $this->getHeraldTranscript(); | |||||
| if ($herald_xscript) { | |||||
Not Done Inline ActionsThis one too. epriestley: This one too. | |||||
| $herald_header = $herald_xscript->getXHeraldRulesHeader(); | |||||
| $herald_header = HeraldTranscript::saveXHeraldRulesHeader( | |||||
| $object->getPHID(), | |||||
| $herald_header); | |||||
| } else { | |||||
| $herald_header = HeraldTranscript::loadXHeraldRulesHeader( | |||||
| $object->getPHID()); | |||||
| } | |||||
| PhabricatorWorker::scheduleTask( | |||||
| $this->getTransactionEmailWorkerClass(), | |||||
| array( | |||||
| 'object' => $object->getPHID(), | |||||
| 'xactions' => mpull($xactions, 'getPHID'), | |||||
| 'mailTo' => $this->getMailTo($object), | |||||
| 'mailCC' => $this->getMailCC($object), | |||||
| 'actingAsPHID' => $this->getActingAsPHID(), | |||||
| 'isNewObject' => $this->getIsNewObject(), | |||||
| 'heraldHeader' => $herald_header, | |||||
| 'excludeMailRecipientPHIDs' => $this->getExcludeMailRecipientPHIDs(), | |||||
| 'parentMessageID' => $this->getParentMessageID(), | |||||
| ), | |||||
| array( | |||||
| 'priority' => PhabricatorWorker::PRIORITY_ALERTS, // FIXME: right prio? | |||||
| )); | |||||
| /* | |||||
| $email_to = array_filter(array_unique($this->getMailTo($object))); | $email_to = array_filter(array_unique($this->getMailTo($object))); | ||||
| $email_cc = array_filter(array_unique($this->getMailCC($object))); | $email_cc = array_filter(array_unique($this->getMailCC($object))); | ||||
| $phids = array_merge($email_to, $email_cc); | $phids = array_merge($email_to, $email_cc); | ||||
| $handles = id(new PhabricatorHandleQuery()) | $handles = id(new PhabricatorHandleQuery()) | ||||
| ->setViewer($this->requireActor()) | ->setViewer($this->requireActor()) | ||||
| ->withPHIDs($phids) | ->withPHIDs($phids) | ||||
| ->execute(); | ->execute(); | ||||
| $template = $this->buildMailTemplate($object); | $template = $this->buildMailTemplate($object); | ||||
| $body = $this->buildMailBody($object, $xactions); | $body = $this->buildMailBody($object, $xactions); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | protected function sendMail( | ||||
| foreach ($mails as $mail) { | foreach ($mails as $mail) { | ||||
| $mail->saveAndSend(); | $mail->saveAndSend(); | ||||
| } | } | ||||
| $template->addTos($email_to); | $template->addTos($email_to); | ||||
| $template->addCCs($email_cc); | $template->addCCs($email_cc); | ||||
| return $template; | return $template;*/ | ||||
| return null; | |||||
| } | } | ||||
| private function addMailProjectMetadata( | /* private function addMailProjectMetadata( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorMetaMTAMail $template) { | PhabricatorMetaMTAMail $template) { | ||||
| $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( | $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( | ||||
| $object->getPHID(), | $object->getPHID(), | ||||
| PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); | PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); | ||||
| if (!$project_phids) { | if (!$project_phids) { | ||||
| Show All 23 Lines | /* private function addMailProjectMetadata( | ||||
| $project_tags = implode(', ', $project_tags); | $project_tags = implode(', ', $project_tags); | ||||
| $template->addHeader('X-Phabricator-Projects', $project_tags); | $template->addHeader('X-Phabricator-Projects', $project_tags); | ||||
| } | } | ||||
| protected function getMailThreadID(PhabricatorLiskDAO $object) { | protected function getMailThreadID(PhabricatorLiskDAO $object) { | ||||
| return $object->getPHID(); | return $object->getPHID(); | ||||
| } | }*/ | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function getStrongestAction( | /* protected function getStrongestAction( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| return last(msort($xactions, 'getActionStrength')); | return last(msort($xactions, 'getActionStrength')); | ||||
| } | }*/ | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function buildReplyHandler(PhabricatorLiskDAO $object) { | /* protected function buildReplyHandler(PhabricatorLiskDAO $object) { | ||||
| throw new Exception('Capability not supported.'); | throw new Exception('Capability not supported.'); | ||||
| } | }*/ | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function getMailSubjectPrefix() { | /* protected function getMailSubjectPrefix() { | ||||
| throw new Exception('Capability not supported.'); | throw new Exception('Capability not supported.'); | ||||
| } | }*/ | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| // FIXME: Only needed for feeds now | |||||
| protected function getMailTags( | protected function getMailTags( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| $tags = array(); | $tags = array(); | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| $tags[] = $xaction->getMailTags(); | $tags[] = $xaction->getMailTags(); | ||||
| } | } | ||||
| return array_mergev($tags); | return array_mergev($tags); | ||||
| } | } | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| public function getMailTagsMap() { | /* public function getMailTagsMap() { | ||||
| // TODO: We should move shared mail tags, like "comment", here. | // TODO: We should move shared mail tags, like "comment", here. | ||||
| return array(); | return array(); | ||||
| } | }*/ | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function getMailAction( | /* protected function getMailAction( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| return $this->getStrongestAction($object, $xactions)->getActionName(); | return $this->getStrongestAction($object, $xactions)->getActionName(); | ||||
| } | }*/ | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function buildMailTemplate(PhabricatorLiskDAO $object) { | /* protected function buildMailTemplate(PhabricatorLiskDAO $object) { | ||||
| throw new Exception('Capability not supported.'); | throw new Exception('Capability not supported.'); | ||||
| } | }*/ | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function getMailTo(PhabricatorLiskDAO $object) { | protected function getMailTo(PhabricatorLiskDAO $object) { | ||||
| throw new Exception('Capability not supported.'); | throw new Exception('Capability not supported.'); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | protected function getMailCC(PhabricatorLiskDAO $object) { | ||||
| return array_mergev($phids); | return array_mergev($phids); | ||||
| } | } | ||||
| /** | /** | ||||
| * @task mail | * @task mail | ||||
| */ | */ | ||||
| protected function buildMailBody( | /* protected function buildMailBody( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| $headers = array(); | $headers = array(); | ||||
| $comments = array(); | $comments = array(); | ||||
| foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
| if ($xaction->shouldHideForMail($xactions)) { | if ($xaction->shouldHideForMail($xactions)) { | ||||
| Show All 30 Lines | if ($object instanceof PhabricatorCustomFieldInterface) { | ||||
| $field->updateTransactionMailBody( | $field->updateTransactionMailBody( | ||||
| $body, | $body, | ||||
| $this, | $this, | ||||
| $xactions); | $xactions); | ||||
| } | } | ||||
| } | } | ||||
| return $body; | return $body; | ||||
| } | }*/ | ||||
| /* -( Publishing Feed Stories )-------------------------------------------- */ | /* -( Publishing Feed Stories )-------------------------------------------- */ | ||||
| /** | /** | ||||
| * @task feed | * @task feed | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines | |||||
This is a good catch, I missed it!