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 = '
'. "

{$author_link} {$verb} this revision.

". '
'; + $content = null; } if ($this->inlines) { @@ -213,6 +215,29 @@ final class DifferentialRevisionCommentView extends AphrontView { $background = "background-image: url('{$uri}');"; } + $metadata_blocks = array(); + $metadata = $comment->getMetadata(); + $added_reviewers = idx( + $metadata, + DifferentialComment::METADATA_ADDED_REVIEWERS); + if ($added_reviewers) { + $reviewers = array(); + foreach ($added_reviewers as $phid) { + $reviewers[] = $this->handles[$phid]->renderLink(); + } + $reviewers = 'Added reviewers: '.implode(', ', $reviewers); + $metadata_blocks[] = $reviewers; + } + + if ($metadata_blocks) { + $metadata_blocks = + '
'. + implode("\n", $metadata_blocks). + '
'; + } else { + $metadata_blocks = null; + } + return phutil_render_tag( 'div', array( @@ -226,6 +251,8 @@ final class DifferentialRevisionCommentView extends AphrontView { ''. '
'. '
'. + $head_content. + $metadata_blocks. '
'. $content. '
'. diff --git a/src/applications/differential/view/revisioncomment/__init__.php b/src/applications/differential/view/revisioncomment/__init__.php index e4667c0379..d240fa85ca 100644 --- a/src/applications/differential/view/revisioncomment/__init__.php +++ b/src/applications/differential/view/revisioncomment/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/action'); +phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'view/base'); diff --git a/src/applications/maniphest/storage/transaction/ManiphestTransaction.php b/src/applications/maniphest/storage/transaction/ManiphestTransaction.php index 191ac6f0f5..ba7e5bf2ec 100644 --- a/src/applications/maniphest/storage/transaction/ManiphestTransaction.php +++ b/src/applications/maniphest/storage/transaction/ManiphestTransaction.php @@ -25,12 +25,14 @@ class ManiphestTransaction extends ManiphestDAO { protected $newValue; protected $comments; protected $cache; + protected $metadata = array(); public function getConfiguration() { return array( self::CONFIG_SERIALIZATION => array( 'oldValue' => self::SERIALIZATION_JSON, 'newValue' => self::SERIALIZATION_JSON, + 'metadata' => self::SERIALIZATION_JSON, ), ) + parent::getConfiguration(); }