Summary: Ref T7477. The various "create a new X via email" applications (Paste, Differential, Maniphest, etc) all have a bunch of duplicate code. The inheritance stack here is generally a little weird. Extend these from a shared parent to reduce the number of callsites I need to change when this API is adjusted for T7477. Test Plan: Ran unit tests. This will get more thorough testing once more pieces are in place. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T7477 Differential Revision: https://secure.phabricator.com/D19950
32 lines
823 B
PHP
32 lines
823 B
PHP
<?php
|
|
|
|
final class ManiphestCreateMailReceiver
|
|
extends PhabricatorApplicationMailReceiver {
|
|
|
|
protected function newApplication() {
|
|
return new PhabricatorManiphestApplication();
|
|
}
|
|
|
|
protected function processReceivedMail(
|
|
PhabricatorMetaMTAReceivedMail $mail,
|
|
PhabricatorUser $sender) {
|
|
|
|
$task = ManiphestTask::initializeNewTask($sender);
|
|
$task->setOriginalEmailSource($mail->getHeader('From'));
|
|
|
|
$handler = new ManiphestReplyHandler();
|
|
$handler->setMailReceiver($task);
|
|
|
|
$handler->setActor($sender);
|
|
$handler->setExcludeMailRecipientPHIDs(
|
|
$mail->loadAllRecipientPHIDs());
|
|
if ($this->getApplicationEmail()) {
|
|
$handler->setApplicationEmail($this->getApplicationEmail());
|
|
}
|
|
$handler->processEmail($mail);
|
|
|
|
$mail->setRelatedPHID($task->getPHID());
|
|
}
|
|
|
|
}
|