Summary: Ref T13053. Adds revision stamps (status, reviewers, etc). Adds Herald rule stamps, like the existing X-Herald-Rules header. Removes the "self" stamps, since you can just write a rule against `whatever(@epriestley)` equivalently. If there's routing logic around this, it can live in the routing layer. This avoids tons of self-actor, self-mention, self-reviewer, self-blocking-reviewer, self-resigned-reviewer, etc., stamps. Use `natcasesort()` instead of `sort()` so that numeric values (like monograms) sort `9, 80, 700` instead of `700, 80, 9`. Remove the commas from rendering since they don't really add anything. Test Plan: Edited tasks and revisions, looked at mail stamps, saw stamps that looked pretty reasonable (with no more self stuff, no more commas, sorting numbers, and Herald stamps). Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13053 Differential Revision: https://secure.phabricator.com/D18997
81 lines
2.2 KiB
PHP
81 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class DifferentialMailEngineExtension
|
|
extends PhabricatorMailEngineExtension {
|
|
|
|
const EXTENSIONKEY = 'differential';
|
|
|
|
public function supportsObject($object) {
|
|
return ($object instanceof DifferentialRevision);
|
|
}
|
|
|
|
public function newMailStampTemplates($object) {
|
|
return array(
|
|
id(new PhabricatorPHIDMailStamp())
|
|
->setKey('author')
|
|
->setLabel(pht('Author')),
|
|
id(new PhabricatorPHIDMailStamp())
|
|
->setKey('reviewer')
|
|
->setLabel(pht('Reviewer')),
|
|
id(new PhabricatorPHIDMailStamp())
|
|
->setKey('blocking-reviewer')
|
|
->setLabel(pht('Reviewer')),
|
|
id(new PhabricatorPHIDMailStamp())
|
|
->setKey('resigned-reviewer')
|
|
->setLabel(pht('Reviewer')),
|
|
id(new PhabricatorPHIDMailStamp())
|
|
->setKey('revision-repository')
|
|
->setLabel(pht('Revision Repository')),
|
|
id(new PhabricatorPHIDMailStamp())
|
|
->setKey('revision-status')
|
|
->setLabel(pht('Revision Status')),
|
|
);
|
|
}
|
|
|
|
public function newMailStamps($object, array $xactions) {
|
|
$editor = $this->getEditor();
|
|
$viewer = $this->getViewer();
|
|
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
->setViewer($viewer)
|
|
->needReviewers(true)
|
|
->withPHIDs(array($object->getPHID()))
|
|
->executeOne();
|
|
|
|
$reviewers = array();
|
|
$blocking = array();
|
|
$resigned = array();
|
|
foreach ($revision->getReviewers() as $reviewer) {
|
|
$reviewer_phid = $reviewer->getReviewerPHID();
|
|
|
|
if ($reviewer->isResigned()) {
|
|
$resigned[] = $reviewer_phid;
|
|
} else {
|
|
$reviewers[] = $reviewer_phid;
|
|
if ($reviewer->isBlocking()) {
|
|
$reviewers[] = $blocking;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->getMailStamp('author')
|
|
->setValue($revision->getAuthorPHID());
|
|
|
|
$this->getMailStamp('reviewer')
|
|
->setValue($reviewers);
|
|
|
|
$this->getMailStamp('blocking-reviewer')
|
|
->setValue($blocking);
|
|
|
|
$this->getMailStamp('resigned-reviewer')
|
|
->setValue($resigned);
|
|
|
|
$this->getMailStamp('revision-repository')
|
|
->setValue($revision->getRepositoryPHID());
|
|
|
|
$this->getMailStamp('revision-status')
|
|
->setValue($revision->getModernRevisionStatus());
|
|
}
|
|
|
|
}
|