Differential D11329 Diff 27202 src/applications/maniphest/worker/PhabricatorManiphestTransactionEmailWorker.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/worker/PhabricatorManiphestTransactionEmailWorker.php
- This file was added.
| <?php | |||||
| final class PhabricatorManiphestTransactionEmailWorker | |||||
| extends PhabricatorApplicationTransactionEmailWorker { | |||||
| protected function loadObject($phid) { | |||||
| $task = id(new ManiphestTaskQuery()) | |||||
| ->withPHIDs(array($phid)) | |||||
| ->setViewer(PhabricatorUser::getOmnipotentUser()) | |||||
| ->executeOne(); | |||||
| return $task; | |||||
| } | |||||
| protected function loadXActions($xactions) { | |||||
| $xactions = id(new ManiphestTransactionQuery()) | |||||
| ->withPHIDs($xactions) | |||||
| ->setViewer(PhabricatorUser::getOmnipotentUser()) | |||||
| ->execute(); | |||||
| return $xactions; | |||||
| } | |||||
| protected function buildReplyHandler(PhabricatorLiskDAO $object) { | |||||
| return id(new ManiphestReplyHandler()) | |||||
| ->setMailReceiver($object); | |||||
| } | |||||
| protected function getMailSubjectPrefix() { | |||||
| return PhabricatorEnv::getEnvConfig('metamta.maniphest.subject-prefix'); | |||||
| } | |||||
| protected function getMailThreadID(PhabricatorLiskDAO $object) { | |||||
| return 'maniphest-task-'.$object->getPHID(); | |||||
| } | |||||
| public function getMailTagsMap() { | |||||
| return array( | |||||
| ManiphestTransaction::MAILTAG_STATUS => | |||||
| pht("A task's status changes."), | |||||
| ManiphestTransaction::MAILTAG_OWNER => | |||||
| pht("A task's owner changes."), | |||||
| ManiphestTransaction::MAILTAG_PRIORITY => | |||||
| pht("A task's priority changes."), | |||||
| ManiphestTransaction::MAILTAG_CC => | |||||
| pht("A task's subscribers change."), | |||||
| ManiphestTransaction::MAILTAG_PROJECTS => | |||||
| pht("A task's associated projects change."), | |||||
| ManiphestTransaction::MAILTAG_UNBLOCK => | |||||
| pht('One of the tasks a task is blocked by changes status.'), | |||||
| ManiphestTransaction::MAILTAG_COLUMN => | |||||
| pht('A task is moved between columns on a workboard.'), | |||||
| ManiphestTransaction::MAILTAG_COMMENT => | |||||
| pht('Someone comments on a task.'), | |||||
| ManiphestTransaction::MAILTAG_OTHER => | |||||
| pht('Other task activity not listed above occurs.'), | |||||
| ); | |||||
| } | |||||
| protected function buildMailTemplate(PhabricatorLiskDAO $object) { | |||||
| $id = $object->getID(); | |||||
| $title = $object->getTitle(); | |||||
| return id(new PhabricatorMetaMTAMail()) | |||||
| ->setSubject("T{$id}: {$title}") | |||||
| ->addHeader('Thread-Topic', "T{$id}: ".$object->getOriginalTitle()); | |||||
| } | |||||
| protected function buildMailBody( | |||||
| PhabricatorLiskDAO $object, | |||||
| array $xactions, | |||||
| PhabricatorUser $viewer) { | |||||
| $body = parent::buildMailBody($object, $xactions, $viewer); | |||||
| if ($this->getIsNewObject()) { | |||||
| $body->addTextSection( | |||||
| pht('TASK DESCRIPTION'), | |||||
| $object->getDescription()); | |||||
| } | |||||
| $body->addLinkSection( | |||||
| pht('TASK DETAIL'), | |||||
| PhabricatorEnv::getProductionURI('/T'.$object->getID())); | |||||
| $board_phids = array(); | |||||
| $type_column = ManiphestTransaction::TYPE_PROJECT_COLUMN; | |||||
| foreach ($xactions as $xaction) { | |||||
| if ($xaction->getTransactionType() == $type_column) { | |||||
| $new = $xaction->getNewValue(); | |||||
| $project_phid = idx($new, 'projectPHID'); | |||||
| if ($project_phid) { | |||||
| $board_phids[] = $project_phid; | |||||
| } | |||||
| } | |||||
| } | |||||
| if ($board_phids) { | |||||
| $projects = id(new PhabricatorProjectQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs($board_phids) | |||||
| ->execute(); | |||||
| foreach ($projects as $project) { | |||||
| $body->addLinkSection( | |||||
| pht('WORKBOARD'), | |||||
| PhabricatorEnv::getProductionURI( | |||||
| '/project/board/'.$project->getID().'/')); | |||||
| } | |||||
| } | |||||
| return $body; | |||||
| } | |||||
| } | |||||