mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Releeph s/isPusher/isAuthoritative/
Summary: Instead of being able to ask if someone was a pusher or not, ask if they are "authoritative" enough to make decisions about Releeph requests. A person is authoritative if a project has pushers, and they are a pusher, or in the case of pusher-less projects, everyone is authoritative. Test Plan: Make a request in a project with no pushers (it is immediately ready to be picked) and a project with pushers (where it requires approval.) Reviewers: wez, epriestley Reviewed By: epriestley CC: epriestley, aran Differential Revision: https://secure.phabricator.com/D5877
This commit is contained in:
parent
be358bddae
commit
961c2c0108
6 changed files with 20 additions and 18 deletions
|
@ -28,12 +28,7 @@ final class ConduitAPI_releephwork_canpush_Method
|
|||
protected function execute(ConduitAPIRequest $request) {
|
||||
$releeph_project = id(new ReleephProject())
|
||||
->loadOneWhere('phid = %s', $request->getValue('projectPHID'));
|
||||
|
||||
if (!$releeph_project->getPushers()) {
|
||||
return true;
|
||||
} else {
|
||||
$user = $request->getUser();
|
||||
return $releeph_project->isPusher($user);
|
||||
}
|
||||
$user = $request->getUser();
|
||||
return $releeph_project->isAuthoritative($user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,13 +94,22 @@ final class ReleephProject extends ReleephDAO
|
|||
return $this->getDetail('pushers', array());
|
||||
}
|
||||
|
||||
public function isPusherPHID($phid) {
|
||||
$pusher_phids = $this->getDetail('pushers', array());
|
||||
return in_array($phid, $pusher_phids);
|
||||
public function isPusher(PhabricatorUser $user) {
|
||||
// TODO Deprecate this once `isPusher` is out of the Facebook codebase.
|
||||
return $this->isAuthoritative($user);
|
||||
}
|
||||
|
||||
public function isPusher(PhabricatorUser $user) {
|
||||
return $this->isPusherPHID($user->getPHID());
|
||||
public function isAuthoritative(PhabricatorUser $user) {
|
||||
return $this->isAuthoritativePHID($user->getPHID());
|
||||
}
|
||||
|
||||
public function isAuthoritativePHID($phid) {
|
||||
$pushers = $this->getPushers();
|
||||
if (!$pushers) {
|
||||
return true;
|
||||
} else {
|
||||
return in_array($phid, $pushers);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadPhabricatorRepository() {
|
||||
|
|
|
@ -65,7 +65,7 @@ final class ReleephRequest extends ReleephDAO {
|
|||
|
||||
$found_pusher_want = false;
|
||||
foreach ($this->userIntents as $phid => $intent) {
|
||||
if ($project->isPusherPHID($phid)) {
|
||||
if ($project->isAuthoritativePHID($phid)) {
|
||||
if ($intent == self::INTENT_PASS) {
|
||||
return self::INTENT_PASS;
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ final class ReleephBranchBoxView extends AphrontView {
|
|||
|
||||
$releeph_project = $br->loadReleephProject();
|
||||
if (!$releeph_project->getPushers() ||
|
||||
$releeph_project->isPusher($this->user)) {
|
||||
$releeph_project->isAuthoritative($this->user)) {
|
||||
|
||||
$buttons[] = phutil_tag(
|
||||
'a',
|
||||
|
|
|
@ -44,9 +44,7 @@ final class ReleephRequestIntentsView extends AphrontView {
|
|||
$intents = $request->getUserIntents();
|
||||
foreach ($intents as $user_phid => $user_intent) {
|
||||
if ($user_intent == $render_intent) {
|
||||
$is_pusher = $project->isPusherPHID($user_phid);
|
||||
|
||||
if ($is_pusher) {
|
||||
if ($project->isAuthoritativePHID($user_phid)) {
|
||||
$pusher_links[] = phutil_tag(
|
||||
'span',
|
||||
array(
|
||||
|
|
|
@ -225,7 +225,7 @@ final class ReleephRequestHeaderView extends AphrontView {
|
|||
$right_buttons = array();
|
||||
|
||||
$user_phid = $this->user->getPHID();
|
||||
$is_pusher = $this->releephProject->isPusherPHID($user_phid);
|
||||
$is_pusher = $this->releephProject->isAuthoritativePHID($user_phid);
|
||||
$is_requestor = $this->releephRequest->getRequestUserPHID() === $user_phid;
|
||||
|
||||
$current_intent = idx(
|
||||
|
|
Loading…
Reference in a new issue