@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 118 lines 2.6 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorConduitToken> 5 */ 6final class PhabricatorConduitTokenQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $objectPHIDs; 11 private $expired; 12 private $tokens; 13 private $tokenTypes; 14 15 public function withExpired($expired) { 16 $this->expired = $expired; 17 return $this; 18 } 19 20 public function withIDs(array $ids) { 21 $this->ids = $ids; 22 return $this; 23 } 24 25 public function withObjectPHIDs(array $phids) { 26 $this->objectPHIDs = $phids; 27 return $this; 28 } 29 30 public function withTokens(array $tokens) { 31 $this->tokens = $tokens; 32 return $this; 33 } 34 35 public function withTokenTypes(array $types) { 36 $this->tokenTypes = $types; 37 return $this; 38 } 39 40 public function newResultObject() { 41 return new PhabricatorConduitToken(); 42 } 43 44 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 45 $where = parent::buildWhereClauseParts($conn); 46 47 if ($this->ids !== null) { 48 $where[] = qsprintf( 49 $conn, 50 'id IN (%Ld)', 51 $this->ids); 52 } 53 54 if ($this->objectPHIDs !== null) { 55 $where[] = qsprintf( 56 $conn, 57 'objectPHID IN (%Ls)', 58 $this->objectPHIDs); 59 } 60 61 if ($this->tokens !== null) { 62 $where[] = qsprintf( 63 $conn, 64 'token IN (%Ls)', 65 $this->tokens); 66 } 67 68 if ($this->tokenTypes !== null) { 69 $where[] = qsprintf( 70 $conn, 71 'tokenType IN (%Ls)', 72 $this->tokenTypes); 73 } 74 75 if ($this->expired !== null) { 76 if ($this->expired) { 77 $where[] = qsprintf( 78 $conn, 79 'expires <= %d', 80 PhabricatorTime::getNow()); 81 } else { 82 $where[] = qsprintf( 83 $conn, 84 'expires IS NULL OR expires > %d', 85 PhabricatorTime::getNow()); 86 } 87 } 88 89 return $where; 90 } 91 92 protected function willFilterPage(array $tokens) { 93 $object_phids = mpull($tokens, 'getObjectPHID'); 94 $objects = id(new PhabricatorObjectQuery()) 95 ->setViewer($this->getViewer()) 96 ->setParentQuery($this) 97 ->withPHIDs($object_phids) 98 ->execute(); 99 $objects = mpull($objects, null, 'getPHID'); 100 101 foreach ($tokens as $key => $token) { 102 $object = idx($objects, $token->getObjectPHID(), null); 103 if (!$object) { 104 $this->didRejectResult($token); 105 unset($tokens[$key]); 106 continue; 107 } 108 $token->attachObject($object); 109 } 110 111 return $tokens; 112 } 113 114 public function getQueryApplicationClass() { 115 return PhabricatorConduitApplication::class; 116 } 117 118}