1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 19:22:42 +01:00

Allow email subject prefixes to be configured

Summary:
This is just fluff to let me mailfilter my local sandbox. Would also allow the
Facebook install to return to "[diff]" if eletuchy is still unhappy about this
change.

Test Plan:
Triggered maniphest/differential emails, had normal prefixes. Overrode prefixes
in my custom config, got sandbox-unique prefixes.

Reviewed By: aran
Reviewers: jungejason, tuomaspelkonen, aran
CC: elgenie, aran
Differential Revision: 291
This commit is contained in:
epriestley 2011-05-16 15:54:41 -07:00
parent 417ca39703
commit 7e675b6687
4 changed files with 21 additions and 8 deletions

View file

@ -167,6 +167,10 @@ return array(
// PhabricatorMailReplyHandler (and possibly of ManiphestReplyHandler). // PhabricatorMailReplyHandler (and possibly of ManiphestReplyHandler).
'metamta.maniphest.reply-handler' => 'ManiphestReplyHandler', 'metamta.maniphest.reply-handler' => 'ManiphestReplyHandler',
// Prefix prepended to mail sent by Maniphest. You can change this to
// distinguish between testing and development installs, for example.
'metamta.maniphest.subject-prefix' => '[Maniphest]',
// See 'metamta.maniphest.reply-handler-domain'. This does the same thing, // See 'metamta.maniphest.reply-handler-domain'. This does the same thing,
// but allows email replies via Differential. // but allows email replies via Differential.
'metamta.differential.reply-handler-domain' => null, 'metamta.differential.reply-handler-domain' => null,
@ -175,6 +179,9 @@ return array(
// affects Differential. // affects Differential.
'metamta.differential.reply-handler' => 'DifferentialReplyHandler', 'metamta.differential.reply-handler' => 'DifferentialReplyHandler',
// Prefix prepended to mail sent by Differential.
'metamta.differential.subject-prefix' => '[Differential]',
// -- Auth ------------------------------------------------------------------ // // -- Auth ------------------------------------------------------------------ //

View file

@ -18,8 +18,6 @@
abstract class DifferentialMail { abstract class DifferentialMail {
const SUBJECT_PREFIX = '[Differential]';
protected $to = array(); protected $to = array();
protected $cc = array(); protected $cc = array();
@ -115,8 +113,12 @@ abstract class DifferentialMail {
} }
} }
protected function getSubjectPrefix() {
return PhabricatorEnv::getEnvConfig('metamta.differential.subject-prefix');
}
protected function buildSubject() { protected function buildSubject() {
return self::SUBJECT_PREFIX.' '.$this->renderSubject(); return trim($this->getSubjectPrefix().' '.$this->renderSubject());
} }
protected function shouldMarkMailAsHTML() { protected function shouldMarkMailAsHTML() {

View file

@ -40,11 +40,10 @@ class DifferentialNewDiffMail extends DifferentialReviewRequestMail {
return parent::buildSubject(); return parent::buildSubject();
} }
$prefix = self::SUBJECT_PREFIX; $prefix = $this->getSubjectPrefix();
$subject = $this->renderSubject(); $subject = $this->renderSubject();
return "{$prefix} {$subject}"; return trim("{$prefix} {$subject}");
} }
protected function renderBody() { protected function renderBody() {

View file

@ -17,7 +17,6 @@
*/ */
class ManiphestTransactionEditor { class ManiphestTransactionEditor {
const SUBJECT_PREFIX = '[Maniphest]';
public function applyTransactions($task, array $transactions) { public function applyTransactions($task, array $transactions) {
@ -130,6 +129,10 @@ class ManiphestTransactionEditor {
$this->sendEmail($task, $transactions, $email_to, $email_cc); $this->sendEmail($task, $transactions, $email_to, $email_cc);
} }
protected function getSubjectPrefix() {
return PhabricatorEnv::getEnvConfig('metamta.maniphest.subject-prefix');
}
private function sendEmail($task, $transactions, $email_to, $email_cc) { private function sendEmail($task, $transactions, $email_to, $email_cc) {
$email_to = array_filter(array_unique($email_to)); $email_to = array_filter(array_unique($email_to));
$email_cc = array_filter(array_unique($email_cc)); $email_cc = array_filter(array_unique($email_cc));
@ -193,9 +196,11 @@ class ManiphestTransactionEditor {
$thread_id = '<maniphest-task-'.$task->getPHID().'>'; $thread_id = '<maniphest-task-'.$task->getPHID().'>';
$task_id = $task->getID(); $task_id = $task->getID();
$title = $task->getTitle(); $title = $task->getTitle();
$prefix = $this->getSubjectPrefix();
$subject = trim("{$prefix} [{$action}] T{$task_id}: {$title}");
$template = id(new PhabricatorMetaMTAMail()) $template = id(new PhabricatorMetaMTAMail())
->setSubject(self::SUBJECT_PREFIX." [{$action}] T{$task_id}: {$title}") ->setSubject($subject)
->setFrom($transaction->getAuthorPHID()) ->setFrom($transaction->getAuthorPHID())
->addHeader('Thread-Topic', 'Maniphest Task '.$task->getID()) ->addHeader('Thread-Topic', 'Maniphest Task '.$task->getID())
->setThreadID($thread_id, $is_create) ->setThreadID($thread_id, $is_create)