1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

[differential] gmail-compatible emails

Summary:
Gmail ignores text inside of [square brackets] when deciding what to group
together. This diff does two things to create the right behavior for gmail:

  1. put the verb text inside of [square brackets] so different verbs don't
  break gmail threading.
  2. Add the Diff ID to the email thread, so different diffs with the same name
  don't group together.

Furthermore, to aid in distinguishing who is doing what when the from field
can't be spoofed, this diff adds the usename just before the verb. This works
quite well in the english language. For example:

  [Differential] [rm requested a review of] D1: [admin] Create arcconfig for
code reviews
  [Differential] [rm commented on] D1: [admin] Create arcconfig for code reviews

It's almost like a complete sentence. All it's missing is a period.

Test Plan:
Did it live on my test setup. Received emails with subjects that looked right.
Verified that gmail grouped the emails despite the different actions taking
place (tested: comments, planned changes, request review).

Reviewed By: epriestley
Reviewers: epriestley, jungejason
CC: aran, epriestley, rm
Differential Revision: 251
This commit is contained in:
Ryan McElroy 2011-05-08 00:35:29 -07:00
parent 1c2222f26f
commit 846d625ed0
2 changed files with 9 additions and 4 deletions

View file

@ -45,9 +45,12 @@ class DifferentialCommentMail extends DifferentialMail {
} }
protected function renderSubject() { protected function renderSubject() {
$verb = ucwords($this->getVerb());
$revision = $this->getRevision(); $revision = $this->getRevision();
$verb = $this->getVerb(); $title = $revision->getTitle();
return ucwords($verb).': '.$revision->getTitle(); $id = $revision->getID();
$subject = "[{$verb}] D{$id}: {$title}";
return $subject;
} }
protected function getVerb() { protected function getVerb() {

View file

@ -17,6 +17,7 @@
*/ */
class ManiphestTransactionEditor { class ManiphestTransactionEditor {
const SUBJECT_PREFIX = '[Maniphest]';
public function applyTransactions($task, array $transactions) { public function applyTransactions($task, array $transactions) {
@ -174,10 +175,11 @@ class ManiphestTransactionEditor {
" ".$task_uri."\n"; " ".$task_uri."\n";
$thread_id = '<maniphest-task-'.$task->getPHID().'>'; $thread_id = '<maniphest-task-'.$task->getPHID().'>';
$task_id = $task->getID();
$title = $task->getTitle();
id(new PhabricatorMetaMTAMail()) id(new PhabricatorMetaMTAMail())
->setSubject( ->setSubject(self::SUBJECT_PREFIX." [{$action}] T{$task_id}: {$title}")
'[Maniphest] T'.$task->getID().' '.$action.': '.$task->getTitle())
->setFrom($transaction->getAuthorPHID()) ->setFrom($transaction->getAuthorPHID())
->addTos($email_to) ->addTos($email_to)
->addCCs($email_cc) ->addCCs($email_cc)