mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Remove PhabricatorOwnersOwner::loadAffiliatedPackages()
Summary: See D3193 for discussion. Test Plan: Ran `owners.query` via conduit, verified I got sensible output. Reviewers: vrana, btrahan, meitros Reviewed By: btrahan CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D3194
This commit is contained in:
parent
8cdd801515
commit
386735a39d
2 changed files with 5 additions and 36 deletions
|
@ -81,26 +81,6 @@ final class ConduitAPI_owners_query_Method
|
|||
return $packages;
|
||||
}
|
||||
|
||||
protected static function queryByAffiliatedUser($owner) {
|
||||
$is_valid_phid =
|
||||
phid_get_type($owner) == PhabricatorPHIDConstants::PHID_TYPE_USER;
|
||||
|
||||
if (!$is_valid_phid) {
|
||||
throw id(new ConduitException('ERR-INVALID-PARAMETER'))
|
||||
->setErrorDescription(
|
||||
'Expected user PHID for affiliation, got '.$owner);
|
||||
}
|
||||
|
||||
$owners = PhabricatorOwnersOwner::loadAffiliatedPackages($owner);
|
||||
|
||||
$package_ids = mpull($owners, 'getPackageID');
|
||||
$packages = array();
|
||||
foreach ($package_ids as $id) {
|
||||
$packages[] = id(new PhabricatorOwnersPackage())->load($id);
|
||||
}
|
||||
return $packages;
|
||||
}
|
||||
|
||||
public static function queryByPath($repo_callsign, $path) {
|
||||
// note: we call this from the deprecated path.getowners conduit call.
|
||||
|
||||
|
@ -165,9 +145,12 @@ final class ConduitAPI_owners_query_Method
|
|||
}
|
||||
|
||||
if ($is_affiliated_query) {
|
||||
$packages = self::queryByAffiliatedUser(
|
||||
$request->getValue('userAffiliated'));
|
||||
$query = id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($request->getUser());
|
||||
|
||||
$query->withOwnerPHIDs(array($request->getValue('userAffiliated')));
|
||||
|
||||
$packages = $query->execute();
|
||||
} else if ($is_owner_query) {
|
||||
$owner = nonempty(
|
||||
$request->getValue('userOwner'),
|
||||
|
|
|
@ -69,18 +69,4 @@ final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO {
|
|||
|
||||
return array_unique(array_merge($users_in_project_phids, $user_phids));
|
||||
}
|
||||
|
||||
// Loads all affiliated packages for a user. This includes packages owned by
|
||||
// any project the user is a member of.
|
||||
public static function loadAffiliatedPackages($user_phid) {
|
||||
$query = new PhabricatorProjectQuery();
|
||||
$query->withMemberPHIDs(array($user_phid));
|
||||
$query->withStatus(PhabricatorProjectQuery::STATUS_ACTIVE);
|
||||
$projects = $query->execute();
|
||||
|
||||
$phids = mpull($projects, 'getPHID') + array($user_phid);
|
||||
return id(new PhabricatorOwnersOwner())->loadAllWhere(
|
||||
'userPHID in (%Ls)',
|
||||
$phids);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue