1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-02 01:48:23 +01:00

Add inline comments to diffusion/audit emails

Summary:
Depends on D1929. In emails, notify recipients that inlines are attached.

Vaguely copy/pastey from Differential but they only share like six lines and this seems like a random piece of code to pull out.

Test Plan: Added inline comments, got email mentioning them

Reviewers: davidreuss, nh, btrahan

Reviewed By: davidreuss

CC: aran, epriestley

Maniphest Tasks: T904

Differential Revision: https://secure.phabricator.com/D1930
This commit is contained in:
epriestley 2012-03-19 19:56:37 -07:00
parent e42c29f4ec
commit e1ccd270fa
2 changed files with 37 additions and 4 deletions

View file

@ -120,7 +120,7 @@ final class PhabricatorAuditCommentEditor {
$this->publishFeedStory($comment, array_keys($audit_phids));
PhabricatorSearchCommitIndexer::indexCommit($commit);
$this->sendMail($comment, $other_comments);
$this->sendMail($comment, $other_comments, $inline_comments);
}
@ -189,7 +189,8 @@ final class PhabricatorAuditCommentEditor {
private function sendMail(
PhabricatorAuditComment $comment,
array $other_comments) {
array $other_comments,
array $inline_comments) {
$commit = $this->commit;
$data = $commit->loadCommitData();
@ -221,7 +222,8 @@ final class PhabricatorAuditCommentEditor {
$comment,
"{$name}: {$summary}",
$handle,
$reply_handler);
$reply_handler,
$inline_comments);
$email_to = array();
@ -276,7 +278,8 @@ final class PhabricatorAuditCommentEditor {
PhabricatorAuditComment $comment,
$cname,
PhabricatorObjectHandle $handle,
PhabricatorMailReplyHandler $reply_handler) {
PhabricatorMailReplyHandler $reply_handler,
array $inline_comments) {
$commit = $this->commit;
$user = $this->user;
@ -292,8 +295,37 @@ final class PhabricatorAuditCommentEditor {
$body[] = $comment->getContent();
}
if ($inline_comments) {
$block = array();
$path_map = id(new DiffusionPathQuery())
->withPathIDs(mpull($inline_comments, 'getPathID'))
->execute();
$path_map = ipull($path_map, 'path', 'id');
foreach ($inline_comments as $inline) {
$path = idx($path_map, $inline->getPathID());
if ($path === null) {
continue;
}
$start = $inline->getLineNumber();
$len = $inline->getLineLength();
if ($len) {
$range = $start.'-'.($start + $len);
} else {
$range = $start;
}
$content = $inline->getContent();
$block[] = "{$path}:{$range} {$content}";
}
$body[] = "INLINE COMMENTS\n ".implode("\n ", $block);
}
$body[] = "COMMIT\n ".PhabricatorEnv::getProductionURI($handle->getURI());
$reply_instructions = $reply_handler->getReplyHandlerInstructions();
if ($reply_instructions) {
$body[] = "REPLY HANDLER ACTIONS\n ".$reply_instructions;

View file

@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/audit/constants/action');
phutil_require_module('phabricator', 'applications/audit/constants/status');
phutil_require_module('phabricator', 'applications/audit/storage/auditcomment');
phutil_require_module('phabricator', 'applications/audit/storage/inlinecommment');
phutil_require_module('phabricator', 'applications/diffusion/query/path');
phutil_require_module('phabricator', 'applications/feed/constants/story');
phutil_require_module('phabricator', 'applications/feed/publisher');
phutil_require_module('phabricator', 'applications/metamta/storage/mail');