Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / people / query / PhabricatorPeopleUserEmailQuery.php
blobead44a56dc3cdbfc9eb32e75dc72ab7870fff2fa
1 <?php
3 final class PhabricatorPeopleUserEmailQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $phids;
9 public function withIDs(array $ids) {
10 $this->ids = $ids;
11 return $this;
14 public function withPHIDs(array $phids) {
15 $this->phids = $phids;
16 return $this;
19 public function newResultObject() {
20 return new PhabricatorUserEmail();
23 protected function getPrimaryTableAlias() {
24 return 'email';
27 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
28 $where = parent::buildWhereClauseParts($conn);
30 if ($this->ids !== null) {
31 $where[] = qsprintf(
32 $conn,
33 'email.id IN (%Ld)',
34 $this->ids);
37 if ($this->phids !== null) {
38 $where[] = qsprintf(
39 $conn,
40 'email.phid IN (%Ls)',
41 $this->phids);
44 return $where;
47 protected function willLoadPage(array $page) {
49 $user_phids = mpull($page, 'getUserPHID');
51 $users = id(new PhabricatorPeopleQuery())
52 ->setViewer($this->getViewer())
53 ->setParentQuery($this)
54 ->withPHIDs($user_phids)
55 ->execute();
56 $users = mpull($users, null, 'getPHID');
58 foreach ($page as $key => $address) {
59 $user = idx($users, $address->getUserPHID());
61 if (!$user) {
62 unset($page[$key]);
63 $this->didRejectResult($address);
64 continue;
67 $address->attachUser($user);
70 return $page;
73 public function getQueryApplicationClass() {
74 return 'PhabricatorPeopleApplication';