mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Integrate Audit into feed
Summary: When a user posts an action in the audit tool, publish it to feed. Test Plan: Made some comments, saw them show up in feed. Reviewers: btrahan, jungejason Reviewed By: jungejason CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1695
This commit is contained in:
parent
26599e6192
commit
053d576ad6
8 changed files with 127 additions and 2 deletions
|
@ -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',
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -8,5 +8,7 @@
|
|||
|
||||
phutil_require_module('phabricator', 'applications/audit/constants/status');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorAuditActionConstants.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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -25,5 +25,6 @@ final class PhabricatorFeedStoryTypeConstants
|
|||
const STORY_PHRICTION = 'PhabricatorFeedStoryPhriction';
|
||||
const STORY_MANIPHEST = 'PhabricatorFeedStoryManiphest';
|
||||
const STORY_PROJECT = 'PhabricatorFeedStoryProject';
|
||||
const STORY_AUDIT = 'PhabricatorFeedStoryAudit';
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorFeedStoryAudit extends PhabricatorFeedStory {
|
||||
|
||||
public function getRequiredHandlePHIDs() {
|
||||
return array(
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
14
src/applications/feed/story/audit/__init__.php
Normal file
14
src/applications/feed/story/audit/__init__.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/audit/constants/action');
|
||||
phutil_require_module('phabricator', 'applications/feed/story/base');
|
||||
phutil_require_module('phabricator', 'applications/feed/view/story');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorFeedStoryAudit.php');
|
Loading…
Reference in a new issue