Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/query/PhabricatorMetaMTAMemberQuery.php
Show All 36 Lines | public function execute() { | ||||
foreach ($type_map as $type => $phids) { | foreach ($type_map as $type => $phids) { | ||||
switch ($type) { | switch ($type) { | ||||
case PhabricatorProjectProjectPHIDType::TYPECONST: | case PhabricatorProjectProjectPHIDType::TYPECONST: | ||||
// NOTE: We're loading the projects here in order to respect policies. | // NOTE: We're loading the projects here in order to respect policies. | ||||
$projects = id(new PhabricatorProjectQuery()) | $projects = id(new PhabricatorProjectQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs($phids) | ->withPHIDs($phids) | ||||
->needMembers(true) | |||||
->needWatchers(true) | |||||
->execute(); | ->execute(); | ||||
$subscribers = id(new PhabricatorSubscribersQuery()) | $edge_type = PhabricatorProjectSilencedEdgeType::EDGECONST; | ||||
->withObjectPHIDs($phids) | |||||
->execute(); | $edge_query = id(new PhabricatorEdgeQuery()) | ||||
->withSourcePHIDs($phids) | |||||
->withEdgeTypes( | |||||
array( | |||||
$edge_type, | |||||
)); | |||||
$edge_query->execute(); | |||||
$projects = mpull($projects, null, 'getPHID'); | $projects = mpull($projects, null, 'getPHID'); | ||||
foreach ($phids as $phid) { | foreach ($phids as $phid) { | ||||
$project = idx($projects, $phid); | $project = idx($projects, $phid); | ||||
if (!$project) { | if (!$project) { | ||||
$results[$phid] = array(); | $results[$phid] = array(); | ||||
} else { | continue; | ||||
$results[$phid] = idx($subscribers, $phid, array()); | |||||
} | } | ||||
// Recipients are members who haven't silenced the project, plus | |||||
// watchers. | |||||
$members = $project->getMemberPHIDs(); | |||||
$members = array_fuse($members); | |||||
$watchers = $project->getWatcherPHIDs(); | |||||
$watchers = array_fuse($watchers); | |||||
$silenced = $edge_query->getDestinationPHIDs( | |||||
array($phid), | |||||
array($edge_type)); | |||||
$silenced = array_fuse($silenced); | |||||
$result_map = array_diff_key($members, $silenced); | |||||
$result_map = $result_map + $watchers; | |||||
$results[$phid] = array_values($result_map); | |||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
// For other types, just map the PHID to itself without modification. | // For other types, just map the PHID to itself without modification. | ||||
// This allows callers to do less work. | // This allows callers to do less work. | ||||
foreach ($phids as $phid) { | foreach ($phids as $phid) { | ||||
$results[$phid] = array($phid); | $results[$phid] = array($phid); | ||||
} | } | ||||
Show All 17 Lines |