diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1299,13 +1299,13 @@ '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', diff --git a/src/applications/chatlog/controller/PhabricatorChatLogChannelListController.php b/src/applications/chatlog/controller/PhabricatorChatLogChannelListController.php --- a/src/applications/chatlog/controller/PhabricatorChatLogChannelListController.php +++ b/src/applications/chatlog/controller/PhabricatorChatLogChannelListController.php @@ -3,6 +3,10 @@ final class PhabricatorChatLogChannelListController extends PhabricatorChatLogController { + public function shouldAllowPublic() { + return true; + } + public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); diff --git a/src/applications/chatlog/controller/PhabricatorChatLogChannelLogController.php b/src/applications/chatlog/controller/PhabricatorChatLogChannelLogController.php --- a/src/applications/chatlog/controller/PhabricatorChatLogChannelLogController.php +++ b/src/applications/chatlog/controller/PhabricatorChatLogChannelLogController.php @@ -5,6 +5,10 @@ private $channelID; + public function shouldAllowPublic() { + return true; + } + public function willProcessRequest(array $data) { $this->channelID = $data['channelID']; } diff --git a/src/applications/chatlog/controller/PhabricatorChatLogController.php b/src/applications/chatlog/controller/PhabricatorChatLogController.php --- a/src/applications/chatlog/controller/PhabricatorChatLogController.php +++ b/src/applications/chatlog/controller/PhabricatorChatLogController.php @@ -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()); - } - } diff --git a/src/applications/chatlog/PhabricatorChatLogChannelQuery.php b/src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php rename from src/applications/chatlog/PhabricatorChatLogChannelQuery.php rename to src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php diff --git a/src/applications/chatlog/PhabricatorChatLogQuery.php b/src/applications/chatlog/query/PhabricatorChatLogQuery.php rename from src/applications/chatlog/PhabricatorChatLogQuery.php rename to src/applications/chatlog/query/PhabricatorChatLogQuery.php --- a/src/applications/chatlog/PhabricatorChatLogQuery.php +++ b/src/applications/chatlog/query/PhabricatorChatLogQuery.php @@ -33,6 +33,28 @@ 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(); diff --git a/src/applications/chatlog/storage/PhabricatorChatLogEvent.php b/src/applications/chatlog/storage/PhabricatorChatLogEvent.php --- a/src/applications/chatlog/storage/PhabricatorChatLogEvent.php +++ b/src/applications/chatlog/storage/PhabricatorChatLogEvent.php @@ -11,6 +11,27 @@ protected $message; protected $loggedByPHID; + private $channel = self::ATTACHABLE; + + public function getConfiguration() { + return array( + self::CONFIG_TIMESTAMPS => false, + ) + 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, @@ -18,24 +39,15 @@ } 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; + return $this->getChannel()->getPolicy($capability); } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { - return false; + return $this->getChannel()->hasAutomaticCapability($capability, $viewer); } public function describeAutomaticCapability($capability) { return null; } - public function getConfiguration() { - return array( - self::CONFIG_TIMESTAMPS => false, - ) + parent::getConfiguration(); - } - }