diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index bc1d6b64a9..4e1aa1c113 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -526,6 +526,7 @@ phutil_register_library_map(array( 'PhabricatorFeedPublicStreamController' => 'applications/feed/controller/publicstream', 'PhabricatorFeedQuery' => 'applications/feed/query', 'PhabricatorFeedStory' => 'applications/feed/story/base', + 'PhabricatorFeedStoryAudit' => 'applications/feed/story/audit', 'PhabricatorFeedStoryData' => 'applications/feed/storage/story', 'PhabricatorFeedStoryDifferential' => 'applications/feed/story/differential', 'PhabricatorFeedStoryManiphest' => 'applications/feed/story/maniphest', @@ -1302,6 +1303,7 @@ phutil_register_library_map(array( 'PhabricatorFeedController' => 'PhabricatorController', 'PhabricatorFeedDAO' => 'PhabricatorLiskDAO', 'PhabricatorFeedPublicStreamController' => 'PhabricatorFeedController', + 'PhabricatorFeedStoryAudit' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryData' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryDifferential' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryManiphest' => 'PhabricatorFeedStory', diff --git a/src/applications/audit/constants/action/PhabricatorAuditActionConstants.php b/src/applications/audit/constants/action/PhabricatorAuditActionConstants.php index c1dbe5a8ba..2bbb116d2b 100644 --- a/src/applications/audit/constants/action/PhabricatorAuditActionConstants.php +++ b/src/applications/audit/constants/action/PhabricatorAuditActionConstants.php @@ -16,7 +16,7 @@ * limitations under the License. */ -class PhabricatorAuditActionConstants { +final class PhabricatorAuditActionConstants { const CONCERN = 'concern'; const ACCEPT = 'accept'; @@ -32,6 +32,15 @@ class PhabricatorAuditActionConstants { return $map; } + public static function getActionPastTenseVerb($action) { + static $map = array( + self::COMMENT => 'commented on', + self::CONCERN => 'raised a concern with', + self::ACCEPT => 'accepted', + ); + return idx($map, $action, 'updated'); + } + public static function getStatusNameMap() { static $map = array( self::CONCERN => PhabricatorAuditStatusConstants::CONCERNED, diff --git a/src/applications/audit/constants/action/__init__.php b/src/applications/audit/constants/action/__init__.php index 449852aef9..a1ffd25b96 100644 --- a/src/applications/audit/constants/action/__init__.php +++ b/src/applications/audit/constants/action/__init__.php @@ -8,5 +8,7 @@ phutil_require_module('phabricator', 'applications/audit/constants/status'); +phutil_require_module('phutil', 'utils'); + phutil_require_source('PhabricatorAuditActionConstants.php'); diff --git a/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php index 95f09b1336..29ffd6b926 100644 --- a/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php +++ b/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php @@ -71,7 +71,8 @@ final class PhabricatorAuditCommentEditor { } } - // TODO: News feed. + $this->publishFeedStory($comment, array_keys($audit_phids)); + // TODO: Search index. // TODO: Email. } @@ -112,4 +113,29 @@ final class PhabricatorAuditCommentEditor { return array_keys($phids); } + private function publishFeedStory($comment, array $more_phids) { + $commit = $this->commit; + $user = $this->user; + + $related_phids = array_merge( + array( + $user->getPHID(), + $commit->getPHID(), + ), + $more_phids); + + id(new PhabricatorFeedStoryPublisher()) + ->setRelatedPHIDs($related_phids) + ->setStoryAuthorPHID($user->getPHID()) + ->setStoryTime(time()) + ->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_AUDIT) + ->setStoryData( + array( + 'commitPHID' => $commit->getPHID(), + 'action' => $comment->getAction(), + 'content' => $comment->getContent(), + )) + ->publish(); + } + } diff --git a/src/applications/audit/editor/comment/__init__.php b/src/applications/audit/editor/comment/__init__.php index b27f027ea4..f362087b9f 100644 --- a/src/applications/audit/editor/comment/__init__.php +++ b/src/applications/audit/editor/comment/__init__.php @@ -7,6 +7,8 @@ phutil_require_module('phabricator', 'applications/audit/constants/action'); +phutil_require_module('phabricator', 'applications/feed/constants/story'); +phutil_require_module('phabricator', 'applications/feed/publisher'); phutil_require_module('phabricator', 'applications/owners/storage/owner'); phutil_require_module('phabricator', 'applications/owners/storage/package'); phutil_require_module('phabricator', 'applications/owners/storage/packagecommitrelationship'); diff --git a/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php b/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php index 0a9de66251..903d87a390 100644 --- a/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php +++ b/src/applications/feed/constants/story/PhabricatorFeedStoryTypeConstants.php @@ -25,5 +25,6 @@ final class PhabricatorFeedStoryTypeConstants const STORY_PHRICTION = 'PhabricatorFeedStoryPhriction'; const STORY_MANIPHEST = 'PhabricatorFeedStoryManiphest'; const STORY_PROJECT = 'PhabricatorFeedStoryProject'; + const STORY_AUDIT = 'PhabricatorFeedStoryAudit'; } diff --git a/src/applications/feed/story/audit/PhabricatorFeedStoryAudit.php b/src/applications/feed/story/audit/PhabricatorFeedStoryAudit.php new file mode 100644 index 0000000000..d6b50aab6a --- /dev/null +++ b/src/applications/feed/story/audit/PhabricatorFeedStoryAudit.php @@ -0,0 +1,69 @@ +getStoryData()->getAuthorPHID(), + $this->getStoryData()->getValue('commitPHID'), + ); + } + + public function getRequiredObjectPHIDs() { + return array(); + } + + public function renderView() { + $data = $this->getStoryData(); + + $author_phid = $data->getAuthorPHID(); + $commit_phid = $data->getValue('commitPHID'); + + $view = new PhabricatorFeedStoryView(); + + $action = $data->getValue('action'); + $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action); + + $view->setTitle( + $this->linkTo($author_phid). + " {$verb} commit ". + $this->linkTo($commit_phid). + "."); + + $view->setEpoch($data->getEpoch()); + + $comments = $data->getValue('content'); + if ($comments) { + $full_size = true; + } else { + $full_size = false; + } + + if ($full_size) { + $view->setImage($this->getHandle($author_phid)->getImageURI()); + $content = $this->renderSummary($data->getValue('content')); + $view->appendChild($content); + } else { + $view->setOneLineStory(true); + } + + return $view; + } + +} diff --git a/src/applications/feed/story/audit/__init__.php b/src/applications/feed/story/audit/__init__.php new file mode 100644 index 0000000000..17faefd3b6 --- /dev/null +++ b/src/applications/feed/story/audit/__init__.php @@ -0,0 +1,14 @@ +