@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 88 lines 2.0 kB view raw
1<?php 2 3final class HarbormasterBuildMessageQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $receiverPHIDs; 8 private $consumed; 9 10 public function withIDs(array $ids) { 11 $this->ids = $ids; 12 return $this; 13 } 14 15 public function withReceiverPHIDs(array $phids) { 16 $this->receiverPHIDs = $phids; 17 return $this; 18 } 19 20 public function withConsumed($consumed) { 21 $this->consumed = $consumed; 22 return $this; 23 } 24 25 public function newResultObject() { 26 return new HarbormasterBuildMessage(); 27 } 28 29 protected function willFilterPage(array $page) { 30 $receiver_phids = array_filter(mpull($page, 'getReceiverPHID')); 31 if ($receiver_phids) { 32 $receivers = id(new PhabricatorObjectQuery()) 33 ->setViewer($this->getViewer()) 34 ->withPHIDs($receiver_phids) 35 ->setParentQuery($this) 36 ->execute(); 37 $receivers = mpull($receivers, null, 'getPHID'); 38 } else { 39 $receivers = array(); 40 } 41 42 foreach ($page as $key => $message) { 43 $receiver_phid = $message->getReceiverPHID(); 44 45 if (empty($receivers[$receiver_phid])) { 46 unset($page[$key]); 47 $this->didRejectResult($message); 48 continue; 49 } 50 51 $message->attachReceiver($receivers[$receiver_phid]); 52 } 53 54 return $page; 55 } 56 57 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 58 $where = parent::buildWhereClauseParts($conn); 59 60 if ($this->ids !== null) { 61 $where[] = qsprintf( 62 $conn, 63 'id IN (%Ld)', 64 $this->ids); 65 } 66 67 if ($this->receiverPHIDs !== null) { 68 $where[] = qsprintf( 69 $conn, 70 'receiverPHID IN (%Ls)', 71 $this->receiverPHIDs); 72 } 73 74 if ($this->consumed !== null) { 75 $where[] = qsprintf( 76 $conn, 77 'isConsumed = %d', 78 (int)$this->consumed); 79 } 80 81 return $where; 82 } 83 84 public function getQueryApplicationClass() { 85 return PhabricatorHarbormasterApplication::class; 86 } 87 88}