mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 11:12:42 +01:00
de01f3e2e0
Summary: Fixes T9369. Test Plan: - Sent a mail with Mail.app to `bugs@local.phacility.com`. - Used "View Raw Mail", copy-pasted it into `mail.txt` on disk. - Ran `cat mail.txt | ./scripts/mail/manage_mail.php --process-duplicates`. - Saw task get created and me get added as CC. - Changed "To" to include another user, ran command again, saw task get created and other user get added as CC. Reviewers: chad Reviewed By: chad Subscribers: Korvin Maniphest Tasks: T9369 Differential Revision: https://secure.phabricator.com/D14086
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class ManiphestReplyHandler
|
|
extends PhabricatorApplicationTransactionReplyHandler {
|
|
|
|
public function validateMailReceiver($mail_receiver) {
|
|
if (!($mail_receiver instanceof ManiphestTask)) {
|
|
throw new Exception(pht('Mail receiver is not a %s!', 'ManiphestTask'));
|
|
}
|
|
}
|
|
|
|
public function getObjectPrefix() {
|
|
return 'T';
|
|
}
|
|
|
|
protected function didReceiveMail(
|
|
PhabricatorMetaMTAReceivedMail $mail,
|
|
$body) {
|
|
|
|
$object = $this->getMailReceiver();
|
|
$is_new = !$object->getID();
|
|
$actor = $this->getActor();
|
|
|
|
$xactions = array();
|
|
|
|
if ($is_new) {
|
|
$xactions[] = $this->newTransaction()
|
|
->setTransactionType(ManiphestTransaction::TYPE_TITLE)
|
|
->setNewValue(nonempty($mail->getSubject(), pht('Untitled Task')));
|
|
|
|
$xactions[] = $this->newTransaction()
|
|
->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION)
|
|
->setNewValue($body);
|
|
|
|
$actor_phid = $actor->getPHID();
|
|
if ($actor_phid) {
|
|
$xactions[] = $this->newTransaction()
|
|
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
|
|
->setNewValue(
|
|
array(
|
|
'+' => array($actor_phid),
|
|
));
|
|
}
|
|
}
|
|
|
|
return $xactions;
|
|
}
|
|
|
|
|
|
}
|