@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+50 -9
+13
src/applications/conduit/query/PhabricatorConduitLogQuery.php
··· 3 3 final class PhabricatorConduitLogQuery 4 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 5 6 + private $callerPHIDs; 6 7 private $methods; 7 8 private $methodStatuses; 9 + 10 + public function withCallerPHIDs(array $phids) { 11 + $this->callerPHIDs = $phids; 12 + return $this; 13 + } 8 14 9 15 public function withMethods(array $methods) { 10 16 $this->methods = $methods; ··· 26 32 27 33 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 28 34 $where = parent::buildWhereClauseParts($conn); 35 + 36 + if ($this->callerPHIDs !== null) { 37 + $where[] = qsprintf( 38 + $conn, 39 + 'callerPHID IN (%Ls)', 40 + $this->callerPHIDs); 41 + } 29 42 30 43 if ($this->methods !== null) { 31 44 $where[] = qsprintf(
+37 -9
src/applications/conduit/query/PhabricatorConduitLogSearchEngine.php
··· 18 18 protected function buildQueryFromParameters(array $map) { 19 19 $query = $this->newQuery(); 20 20 21 + if ($map['callerPHIDs']) { 22 + $query->withCallerPHIDs($map['callerPHIDs']); 23 + } 24 + 21 25 if ($map['methods']) { 22 26 $query->withMethods($map['methods']); 23 27 } ··· 31 35 32 36 protected function buildCustomSearchFields() { 33 37 return array( 38 + id(new PhabricatorUsersSearchField()) 39 + ->setKey('callerPHIDs') 40 + ->setLabel(pht('Methods')) 41 + ->setAliases(array('caller', 'callers')) 42 + ->setDescription(pht('Find calls by specific users.')), 34 43 id(new PhabricatorSearchStringListField()) 35 44 ->setKey('methods') 36 45 ->setLabel(pht('Methods')) ··· 39 48 ->setKey('statuses') 40 49 ->setLabel(pht('Method Status')) 41 50 ->setAliases(array('status')) 51 + ->setDescription( 52 + pht('Find calls to stable, unstable, or deprecated methods.')) 42 53 ->setOptions(ConduitAPIMethod::getMethodStatusMap()), 43 54 ); 44 55 } ··· 48 59 } 49 60 50 61 protected function getBuiltinQueryNames() { 51 - $names = array( 52 - 'all' => pht('All Logs'), 53 - 'deprecated' => pht('Deprecated Calls'), 54 - ); 62 + $names = array(); 63 + 64 + $viewer = $this->requireViewer(); 65 + if ($viewer->isLoggedIn()) { 66 + $names['viewer'] = pht('My Calls'); 67 + $names['viewerdeprecated'] = pht('My Deprecated Calls'); 68 + } 69 + 70 + $names['all'] = pht('All Call Logs'); 71 + $names['deprecated'] = pht('Deprecated Call Logs'); 55 72 56 73 return $names; 57 74 } ··· 60 77 $query = $this->newSavedQuery(); 61 78 $query->setQueryKey($query_key); 62 79 80 + $viewer = $this->requireViewer(); 81 + $viewer_phid = $viewer->getPHID(); 82 + 83 + $deprecated = array( 84 + ConduitAPIMethod::METHOD_STATUS_DEPRECATED, 85 + ); 86 + 63 87 switch ($query_key) { 88 + case 'viewer': 89 + return $query 90 + ->setParameter('callerPHIDs', array($viewer_phid)); 91 + case 'viewerdeprecated': 92 + return $query 93 + ->setParameter('callerPHIDs', array($viewer_phid)) 94 + ->setParameter('statuses', $deprecated); 64 95 case 'deprecated': 65 - return $query->setParameter( 66 - 'statuses', 67 - array( 68 - ConduitAPIMethod::METHOD_STATUS_DEPRECATED, 69 - )); 96 + return $query 97 + ->setParameter('statuses', $deprecated); 70 98 case 'all': 71 99 return $query; 72 100 }