mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
3a8eb28a07
Summary: Ref T2222. Adds basic support for email. Test Plan: Received an email via `/editpro/`. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8303
175 lines
4.7 KiB
PHP
175 lines
4.7 KiB
PHP
<?php
|
|
|
|
final class DifferentialTransactionEditor
|
|
extends PhabricatorApplicationTransactionEditor {
|
|
|
|
public function getTransactionTypes() {
|
|
$types = parent::getTransactionTypes();
|
|
|
|
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
|
|
|
/*
|
|
|
|
$types[] = DifferentialTransaction::TYPE_INLINE;
|
|
$types[] = DifferentialTransaction::TYPE_UPDATE;
|
|
$types[] = DifferentialTransaction::TYPE_ACTION;
|
|
*/
|
|
|
|
return $types;
|
|
}
|
|
|
|
protected function getCustomTransactionOldValue(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
return $object->getViewPolicy();
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
return $object->getEditPolicy();
|
|
}
|
|
|
|
return parent::getCustomTransactionOldValue($object, $xaction);
|
|
}
|
|
|
|
protected function getCustomTransactionNewValue(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
return $xaction->getNewValue();
|
|
}
|
|
|
|
return parent::getCustomTransactionNewValue($object, $xaction);
|
|
}
|
|
|
|
protected function applyCustomInternalTransaction(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
$object->setViewPolicy($xaction->getNewValue());
|
|
return;
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
$object->setEditPolicy($xaction->getNewValue());
|
|
return;
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
|
// TODO: When removing reviewers, we may be able to move the revision
|
|
// to "Accepted".
|
|
return;
|
|
}
|
|
|
|
return parent::applyCustomInternalTransaction($object, $xaction);
|
|
}
|
|
|
|
protected function applyCustomExternalTransaction(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
return;
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
|
return;
|
|
}
|
|
|
|
return parent::applyCustomExternalTransaction($object, $xaction);
|
|
}
|
|
|
|
protected function validateTransaction(
|
|
PhabricatorLiskDAO $object,
|
|
$type,
|
|
array $xactions) {
|
|
|
|
$errors = parent::validateTransaction($object, $type, $xactions);
|
|
|
|
switch ($type) {
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
|
|
protected function requireCapabilities(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
}
|
|
|
|
return parent::requireCapabilities($object, $xaction);
|
|
}
|
|
|
|
protected function shouldSendMail(
|
|
PhabricatorLiskDAO $object,
|
|
array $xactions) {
|
|
return true;
|
|
}
|
|
|
|
protected function getMailTo(PhabricatorLiskDAO $object) {
|
|
$phids = array();
|
|
$phids[] = $object->getAuthorPHID();
|
|
foreach ($object->getReviewerStatus() as $reviewer) {
|
|
$phids[] = $reviewer->getReviewerPHID();
|
|
}
|
|
return $phids;
|
|
}
|
|
|
|
protected function getMailSubjectPrefix() {
|
|
return PhabricatorEnv::getEnvConfig('metamta.differential.subject-prefix');
|
|
}
|
|
|
|
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
|
|
return id(new DifferentialReplyHandler())
|
|
->setMailReceiver($object);
|
|
}
|
|
|
|
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
|
|
$id = $object->getID();
|
|
$title = $object->getTitle();
|
|
|
|
$original_title = $object->getOriginalTitle();
|
|
|
|
$subject = "D{$id}: {$title}";
|
|
$thread_topic = "D{$id}: {$original_title}";
|
|
|
|
return id(new PhabricatorMetaMTAMail())
|
|
->setSubject($subject)
|
|
->addHeader('Thread-Topic', $thread_topic);
|
|
}
|
|
|
|
protected function buildMailBody(
|
|
PhabricatorLiskDAO $object,
|
|
array $xactions) {
|
|
|
|
$body = parent::buildMailBody($object, $xactions);
|
|
|
|
$body->addTextSection(
|
|
pht('REVISION DETAIL'),
|
|
PhabricatorEnv::getProductionURI('/D'.$object->getID()));
|
|
|
|
return $body;
|
|
}
|
|
|
|
protected function supportsSearch() {
|
|
return true;
|
|
}
|
|
|
|
protected function extractFilePHIDsFromCustomTransaction(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
}
|
|
|
|
return parent::extractFilePHIDsFromCustomTransaction($object, $xaction);
|
|
}
|
|
|
|
}
|