diff --git a/roles/phabricator/files/RepositoryAuthorPolicyRule.php b/roles/phabricator/files/RepositoryAuthorPolicyRule.php index 0f0579e..c579d45 100644 --- a/roles/phabricator/files/RepositoryAuthorPolicyRule.php +++ b/roles/phabricator/files/RepositoryAuthorPolicyRule.php @@ -1,71 +1,66 @@ getPHID(); if (!$viewer_phid) { return false; } - // Check if the repository exists, if it doesn't we authorize. The user always - // needs at least the read policy to be able to edit/push so it's not problematic - $repo = id(new PhabricatorRepositoryQuery()) - ->setViewer($viewer) - ->withPHIDs(array($object->getPHID())) - ->withStatus(PhabricatorRepositoryQuery::STATUS_OPEN) - ->execute(); - - if(!$repo) { + // If the repository doesn't exist, we allow the user to create it + $repo_phid = $object->getPHID(); + if(!$repo_phid){ return true; } // Get all repositories the user has created $repo_transaction = id(new PhabricatorRepositoryTransactionQuery()) - ->setViewer($viewer) + ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withAuthorPHIDs(array($viewer_phid)) ->withTransactionTypes(array(PhabricatorTransactions::TYPE_CREATE)) ->execute(); // Check if the current repository has been created by the user if(!empty($repo_transaction)) { $repo_phids = mpull($repo_transaction, 'getObjectPHID'); - if(in_array($object->getPHID(), $repo_phids, true) == true){ + if(in_array($repo_phid, $repo_phids, true) == true){ return true; } } return false; } public function getValueControlType() { return self::CONTROL_TYPE_NONE; } }