mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Modernize chatlog a bit
Summary: Ref T4786. This doesn't fully fix the issue since there's no way to make channels public yet, but gets some of the infrastructure more up to date. - Allow public access to the list and log controllers. - Implement proper policy checks in the Events (this has no practical impact on the only controller that loads this stuff, it's just for general/future purposes). - Remove a old-style unused method for building page frames. Test Plan: Viewed log list and log details as logged-in and logged out users. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4786 Differential Revision: https://secure.phabricator.com/D8746
This commit is contained in:
parent
ab7d89edc8
commit
facd3ea8ef
7 changed files with 64 additions and 35 deletions
|
@ -1299,13 +1299,13 @@ phutil_register_library_map(array(
|
|||
'PhabricatorChatLogChannel' => 'applications/chatlog/storage/PhabricatorChatLogChannel.php',
|
||||
'PhabricatorChatLogChannelListController' => 'applications/chatlog/controller/PhabricatorChatLogChannelListController.php',
|
||||
'PhabricatorChatLogChannelLogController' => 'applications/chatlog/controller/PhabricatorChatLogChannelLogController.php',
|
||||
'PhabricatorChatLogChannelQuery' => 'applications/chatlog/PhabricatorChatLogChannelQuery.php',
|
||||
'PhabricatorChatLogChannelQuery' => 'applications/chatlog/query/PhabricatorChatLogChannelQuery.php',
|
||||
'PhabricatorChatLogConstants' => 'applications/chatlog/constants/PhabricatorChatLogConstants.php',
|
||||
'PhabricatorChatLogController' => 'applications/chatlog/controller/PhabricatorChatLogController.php',
|
||||
'PhabricatorChatLogDAO' => 'applications/chatlog/storage/PhabricatorChatLogDAO.php',
|
||||
'PhabricatorChatLogEvent' => 'applications/chatlog/storage/PhabricatorChatLogEvent.php',
|
||||
'PhabricatorChatLogEventType' => 'applications/chatlog/constants/PhabricatorChatLogEventType.php',
|
||||
'PhabricatorChatLogQuery' => 'applications/chatlog/PhabricatorChatLogQuery.php',
|
||||
'PhabricatorChatLogQuery' => 'applications/chatlog/query/PhabricatorChatLogQuery.php',
|
||||
'PhabricatorCommitBranchesField' => 'applications/repository/customfield/PhabricatorCommitBranchesField.php',
|
||||
'PhabricatorCommitCustomField' => 'applications/repository/customfield/PhabricatorCommitCustomField.php',
|
||||
'PhabricatorCommitTagsField' => 'applications/repository/customfield/PhabricatorCommitTagsField.php',
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
final class PhabricatorChatLogChannelListController
|
||||
extends PhabricatorChatLogController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
|
|
@ -5,6 +5,10 @@ final class PhabricatorChatLogChannelLogController
|
|||
|
||||
private $channelID;
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->channelID = $data['channelID'];
|
||||
}
|
||||
|
|
|
@ -2,17 +2,4 @@
|
|||
|
||||
abstract class PhabricatorChatLogController extends PhabricatorController {
|
||||
|
||||
public function buildStandardPageResponse($view, array $data) {
|
||||
$page = $this->buildStandardPageView();
|
||||
|
||||
$page->setApplicationName(pht('Chat Log'));
|
||||
$page->setBaseURI('/chatlog/');
|
||||
$page->setTitle(idx($data, 'title'));
|
||||
$page->setGlyph('#');
|
||||
$page->appendChild($view);
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
return $response->setContent($page->render());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,28 @@ final class PhabricatorChatLogQuery
|
|||
return $logs;
|
||||
}
|
||||
|
||||
public function willFilterPage(array $events) {
|
||||
$channel_ids = mpull($events, 'getChannelID', 'getChannelID');
|
||||
|
||||
$channels = id(new PhabricatorChatLogChannelQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withIDs($channel_ids)
|
||||
->execute();
|
||||
$channels = mpull($channels, null, 'getID');
|
||||
|
||||
foreach ($events as $key => $event) {
|
||||
$channel = idx($channels, $event->getChannelID());
|
||||
if (!$channel) {
|
||||
unset($events[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$event->attachChannel($channel);
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
private function buildWhereClause($conn_r) {
|
||||
$where = array();
|
||||
|
|
@ -11,26 +11,7 @@ final class PhabricatorChatLogEvent
|
|||
protected $message;
|
||||
protected $loggedByPHID;
|
||||
|
||||
public function getCapabilities() {
|
||||
return array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
);
|
||||
}
|
||||
|
||||
public function getPolicy($capability) {
|
||||
// TODO: This is sort of silly and mostly just so that we can use
|
||||
// CursorPagedPolicyAwareQuery; once we implement Channel objects we should
|
||||
// just delegate policy to them.
|
||||
return PhabricatorPolicies::POLICY_PUBLIC;
|
||||
}
|
||||
|
||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function describeAutomaticCapability($capability) {
|
||||
return null;
|
||||
}
|
||||
private $channel = self::ATTACHABLE;
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
|
@ -38,4 +19,35 @@ final class PhabricatorChatLogEvent
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function attachChannel(PhabricatorChatLogChannel $channel) {
|
||||
$this->channel = $channel;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChannel() {
|
||||
return $this->assertAttached($this->channel);
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
||||
public function getCapabilities() {
|
||||
return array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
);
|
||||
}
|
||||
|
||||
public function getPolicy($capability) {
|
||||
return $this->getChannel()->getPolicy($capability);
|
||||
}
|
||||
|
||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
||||
return $this->getChannel()->hasAutomaticCapability($capability, $viewer);
|
||||
}
|
||||
|
||||
public function describeAutomaticCapability($capability) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue