1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-08 10:24:48 +01:00

Allow audit email to generate from multiple transactions

Summary: Ref T4896. Begins laying groundwork to split comments apart so they behave like transactions, ultimately enabling the migration.

Test Plan: Made several different types of comments, verified resulting email looks OK.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T4896

Differential Revision: https://secure.phabricator.com/D10022
This commit is contained in:
epriestley 2014-07-24 18:00:41 -07:00
parent 3d78c0eff7
commit 9700589279

View file

@ -304,7 +304,11 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
->queueDocumentForIndexing($commit->getPHID());
if (!$this->noEmail) {
$this->sendMail($comment, $other_comments, $inline_comments, $requests);
$this->sendMail(
array($comment),
$other_comments,
$inline_comments,
$requests);
}
}
@ -374,14 +378,17 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
}
private function sendMail(
PhabricatorAuditComment $comment,
array $comments,
array $other_comments,
array $inline_comments,
array $requests) {
assert_instances_of($comments, 'PhabricatorAuditComment');
assert_instances_of($other_comments, 'PhabricatorAuditComment');
assert_instances_of($inline_comments, 'PhabricatorInlineCommentInterface');
$any_comment = head($comments);
$commit = $this->commit;
$data = $commit->loadCommitData();
@ -405,7 +412,7 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
PhabricatorAuditActionConstants::ADD_CCS => 'Added CCs',
PhabricatorAuditActionConstants::ADD_AUDITORS => 'Added Auditors',
);
$verb = idx($map, $comment->getAction(), 'Commented On');
$verb = idx($map, $any_comment->getAction(), 'Commented On');
$reply_handler = self::newReplyHandlerForCommit($commit);
@ -419,7 +426,7 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
list($thread_id, $thread_topic) = $threading;
$body = $this->renderMailBody(
$comment,
$comments,
"{$name}: {$summary}",
$handle,
$reply_handler,
@ -428,7 +435,7 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
$email_to = array();
$email_cc = array();
$email_to[$comment->getActorPHID()] = true;
$email_to[$any_comment->getActorPHID()] = true;
$author_phid = $data->getCommitDetail('authorPHID');
if ($author_phid) {
@ -472,7 +479,7 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
->setSubject("{$name}: {$summary}")
->setSubjectPrefix($prefix)
->setVarySubjectPrefix("[{$verb}]")
->setFrom($comment->getActorPHID())
->setFrom($any_comment->getActorPHID())
->setThreadID($thread_id, $is_new)
->addHeader('Thread-Topic', $thread_topic)
->setRelatedPHID($commit->getPHID())
@ -508,23 +515,31 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
}
private function renderMailBody(
PhabricatorAuditComment $comment,
array $comments,
$cname,
PhabricatorObjectHandle $handle,
PhabricatorMailReplyHandler $reply_handler,
array $inline_comments) {
assert_instances_of($comments, 'PhabricatorAuditComment');
assert_instances_of($inline_comments, 'PhabricatorInlineCommentInterface');
$commit = $this->commit;
$actor = $this->getActor();
$name = $actor->getUsername();
$verb = PhabricatorAuditActionConstants::getActionPastTenseVerb(
$comment->getAction());
$body = new PhabricatorMetaMTAMailBody();
$body->addRawSection("{$name} {$verb} commit {$cname}.");
$body->addRawSection($comment->getContent());
foreach ($comments as $comment) {
$verb = PhabricatorAuditActionConstants::getActionPastTenseVerb(
$comment->getAction());
$body->addRawSection("{$name} {$verb} commit {$cname}.");
$content = $comment->getContent();
if (strlen($content)) {
$body->addRawSection($comment->getContent());
}
}
if ($inline_comments) {
$block = array();