@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.

at recaptime-dev/main 81 lines 2.0 kB view raw
1<?php 2 3final class PhabricatorAuthQueryPublicKeysConduitAPIMethod 4 extends PhabricatorAuthConduitAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'auth.querypublickeys'; 8 } 9 10 public function getMethodDescription() { 11 return pht('Query public keys.'); 12 } 13 14 protected function defineParamTypes() { 15 return array( 16 'ids' => 'optional list<id>', 17 'phids' => 'optional list<phid>', 18 'objectPHIDs' => 'optional list<phid>', 19 'keys' => 'optional list<string>', 20 ) + self::getPagerParamTypes(); 21 } 22 23 protected function defineReturnType() { 24 return 'result-set'; 25 } 26 27 protected function execute(ConduitAPIRequest $request) { 28 $viewer = $request->getUser(); 29 30 $query = id(new PhabricatorAuthSSHKeyQuery()) 31 ->setViewer($viewer) 32 ->withIsActive(true); 33 34 $ids = $request->getValue('ids'); 35 if ($ids !== null) { 36 $query->withIDs($ids); 37 } 38 39 $phids = $request->getValue('phids'); 40 if ($phids !== null) { 41 $query->withPHIDs($phids); 42 } 43 44 $object_phids = $request->getValue('objectPHIDs'); 45 if ($object_phids !== null) { 46 $query->withObjectPHIDs($object_phids); 47 } 48 49 $keys = $request->getValue('keys'); 50 if ($keys !== null) { 51 $key_objects = array(); 52 foreach ($keys as $key) { 53 $key_objects[] = PhabricatorAuthSSHPublicKey::newFromRawKey($key); 54 } 55 56 $query->withKeys($key_objects); 57 } 58 59 $pager = $this->newPager($request); 60 $public_keys = $query->executeWithCursorPager($pager); 61 62 $data = array(); 63 foreach ($public_keys as $public_key) { 64 $data[] = array( 65 'id' => $public_key->getID(), 66 'name' => $public_key->getName(), 67 'phid' => $public_key->getPHID(), 68 'objectPHID' => $public_key->getObjectPHID(), 69 'isTrusted' => (bool)$public_key->getIsTrusted(), 70 'key' => $public_key->getEntireKey(), 71 ); 72 } 73 74 $results = array( 75 'data' => $data, 76 ); 77 78 return $this->addPagerResults($results, $pager); 79 } 80 81}