mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Add by-caller lookup to call logs, plus viewer calls
Summary: Ref T9980. By default, show the viewer //their// calls. Make it easy to find their own deprecated calls. I don't like the word "My" but couldn't come up with anything better that didn't feel like a big loss of clarity. The permissions on this log are also a little weird: non-admins can see everyone else's calls. I think we should eventually lock that down, but plan to keep it this way for now: First, a lot of your calls end up with no caller set right now, because we don't set the caller early enough in the process so a lot differnet types of errors can leave us with no user on the log. Fixing that isn't trivial, and users may reasonably want to access to these "no caller" logs to check for errors or debug stuff. Second, none of it is really that sensitive? Third, it's reasonable for users to want to look at bots? I'd plan to maybe do this eventually: - Make the caller get populated more often after auth code is simplified. - Only let users look at their calls and maybe bot calls and anonymous calls. - Let admins look at everything. But for now everyone can see everything. Test Plan: {F1025867} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9980 Differential Revision: https://secure.phabricator.com/D14782
This commit is contained in:
parent
6580bbdf39
commit
2805ba6f42
2 changed files with 50 additions and 9 deletions
|
@ -3,9 +3,15 @@
|
|||
final class PhabricatorConduitLogQuery
|
||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||
|
||||
private $callerPHIDs;
|
||||
private $methods;
|
||||
private $methodStatuses;
|
||||
|
||||
public function withCallerPHIDs(array $phids) {
|
||||
$this->callerPHIDs = $phids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withMethods(array $methods) {
|
||||
$this->methods = $methods;
|
||||
return $this;
|
||||
|
@ -27,6 +33,13 @@ final class PhabricatorConduitLogQuery
|
|||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||
$where = parent::buildWhereClauseParts($conn);
|
||||
|
||||
if ($this->callerPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'callerPHID IN (%Ls)',
|
||||
$this->callerPHIDs);
|
||||
}
|
||||
|
||||
if ($this->methods !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
|
|
|
@ -18,6 +18,10 @@ final class PhabricatorConduitLogSearchEngine
|
|||
protected function buildQueryFromParameters(array $map) {
|
||||
$query = $this->newQuery();
|
||||
|
||||
if ($map['callerPHIDs']) {
|
||||
$query->withCallerPHIDs($map['callerPHIDs']);
|
||||
}
|
||||
|
||||
if ($map['methods']) {
|
||||
$query->withMethods($map['methods']);
|
||||
}
|
||||
|
@ -31,6 +35,11 @@ final class PhabricatorConduitLogSearchEngine
|
|||
|
||||
protected function buildCustomSearchFields() {
|
||||
return array(
|
||||
id(new PhabricatorUsersSearchField())
|
||||
->setKey('callerPHIDs')
|
||||
->setLabel(pht('Methods'))
|
||||
->setAliases(array('caller', 'callers'))
|
||||
->setDescription(pht('Find calls by specific users.')),
|
||||
id(new PhabricatorSearchStringListField())
|
||||
->setKey('methods')
|
||||
->setLabel(pht('Methods'))
|
||||
|
@ -39,6 +48,8 @@ final class PhabricatorConduitLogSearchEngine
|
|||
->setKey('statuses')
|
||||
->setLabel(pht('Method Status'))
|
||||
->setAliases(array('status'))
|
||||
->setDescription(
|
||||
pht('Find calls to stable, unstable, or deprecated methods.'))
|
||||
->setOptions(ConduitAPIMethod::getMethodStatusMap()),
|
||||
);
|
||||
}
|
||||
|
@ -48,10 +59,16 @@ final class PhabricatorConduitLogSearchEngine
|
|||
}
|
||||
|
||||
protected function getBuiltinQueryNames() {
|
||||
$names = array(
|
||||
'all' => pht('All Logs'),
|
||||
'deprecated' => pht('Deprecated Calls'),
|
||||
);
|
||||
$names = array();
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
if ($viewer->isLoggedIn()) {
|
||||
$names['viewer'] = pht('My Calls');
|
||||
$names['viewerdeprecated'] = pht('My Deprecated Calls');
|
||||
}
|
||||
|
||||
$names['all'] = pht('All Call Logs');
|
||||
$names['deprecated'] = pht('Deprecated Call Logs');
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
@ -60,13 +77,24 @@ final class PhabricatorConduitLogSearchEngine
|
|||
$query = $this->newSavedQuery();
|
||||
$query->setQueryKey($query_key);
|
||||
|
||||
$viewer = $this->requireViewer();
|
||||
$viewer_phid = $viewer->getPHID();
|
||||
|
||||
$deprecated = array(
|
||||
ConduitAPIMethod::METHOD_STATUS_DEPRECATED,
|
||||
);
|
||||
|
||||
switch ($query_key) {
|
||||
case 'viewer':
|
||||
return $query
|
||||
->setParameter('callerPHIDs', array($viewer_phid));
|
||||
case 'viewerdeprecated':
|
||||
return $query
|
||||
->setParameter('callerPHIDs', array($viewer_phid))
|
||||
->setParameter('statuses', $deprecated);
|
||||
case 'deprecated':
|
||||
return $query->setParameter(
|
||||
'statuses',
|
||||
array(
|
||||
ConduitAPIMethod::METHOD_STATUS_DEPRECATED,
|
||||
));
|
||||
return $query
|
||||
->setParameter('statuses', $deprecated);
|
||||
case 'all':
|
||||
return $query;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue