diff --git a/resources/sql/patches/042.commentmetadata.sql b/resources/sql/patches/042.commentmetadata.sql new file mode 100644 index 0000000000..1b27799732 --- /dev/null +++ b/resources/sql/patches/042.commentmetadata.sql @@ -0,0 +1,11 @@ +ALTER TABLE phabricator_differential.differential_comment + ADD metadata LONGBLOB NOT NULL; + +UPDATE phabricator_differential.differential_comment + SET metadata = '{}' WHERE metadata = ''; + +ALTER TABLE phabricator_maniphest.maniphest_transaction + ADD metadata LONGBLOB NOT NULL; + +UPDATE phabricator_maniphest.maniphest_transaction + SET metadata = '{}' WHERE metadata = ''; diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index 6fee204b02..f9b4a7748f 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -78,6 +78,19 @@ class DifferentialRevisionViewController extends DifferentialController { $user->getPHID(), ), mpull($comments, 'getAuthorPHID')); + + foreach ($comments as $comment) { + $metadata = $comment->getMetadata(); + $added_reviewers = idx( + $metadata, + DifferentialComment::METADATA_ADDED_REVIEWERS); + if ($added_reviewers) { + foreach ($added_reviewers as $phid) { + $object_phids[] = $phid; + } + } + } + foreach ($revision->getAttached() as $type => $phids) { foreach ($phids as $phid => $info) { $object_phids[] = $phid; diff --git a/src/applications/differential/editor/comment/DifferentialCommentEditor.php b/src/applications/differential/editor/comment/DifferentialCommentEditor.php index 7fb98ee6c4..03a919f96b 100644 --- a/src/applications/differential/editor/comment/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/comment/DifferentialCommentEditor.php @@ -84,6 +84,8 @@ class DifferentialCommentEditor { $reviewer_phids = array_combine($reviewer_phids, $reviewer_phids); } + $metadata = array(); + switch ($action) { case DifferentialAction::ACTION_COMMENT: break; @@ -242,13 +244,8 @@ class DifferentialCommentEditor { $add = $added_reviewers, $actor_phid); - $handles = id(new PhabricatorObjectHandleData($added_reviewers)) - ->loadHandles(); - $usernames = mpull($handles, 'getName'); - - $this->message = - 'Added reviewers: '.implode(', ', $usernames)."\n\n". - $this->message; + $key = DifferentialComment::METADATA_ADDED_REVIEWERS; + $metadata[$key] = $added_reviewers; } else { $action = DifferentialAction::ACTION_COMMENT; @@ -282,6 +279,7 @@ class DifferentialCommentEditor { ->setRevisionID($revision->getID()) ->setAction($action) ->setContent((string)$this->message) + ->setMetadata($metadata) ->save(); $changesets = array(); diff --git a/src/applications/differential/storage/comment/DifferentialComment.php b/src/applications/differential/storage/comment/DifferentialComment.php index 1349ddc772..8eebf0afe3 100644 --- a/src/applications/differential/storage/comment/DifferentialComment.php +++ b/src/applications/differential/storage/comment/DifferentialComment.php @@ -18,10 +18,21 @@ class DifferentialComment extends DifferentialDAO { + const METADATA_ADDED_REVIEWERS = 'added-reviewers'; + protected $authorPHID; protected $revisionID; protected $action; protected $content; protected $cache; + protected $metadata = array(); + + public function getConfiguration() { + return array( + self::CONFIG_SERIALIZATION => array( + 'metadata' => self::SERIALIZATION_JSON, + ), + ) + parent::getConfiguration(); + } } diff --git a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php index 62e710be47..73f07f0973 100644 --- a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php +++ b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php @@ -109,6 +109,7 @@ final class DifferentialRevisionCommentView extends AphrontView { $verb = phutil_escape_html($verb); $content = $comment->getContent(); + $head_content = null; if (strlen(rtrim($content))) { $title = "{$author_link} {$verb} this revision:"; $cache = $comment->getCache(); @@ -127,10 +128,11 @@ final class DifferentialRevisionCommentView extends AphrontView { ''; } else { $title = null; - $content = + $head_content = '
'; + } else { + $metadata_blocks = null; + } + return phutil_render_tag( 'div', array( @@ -226,6 +251,8 @@ final class DifferentialRevisionCommentView extends AphrontView { ''. '
{$author_link} {$verb} this revision.
". '