1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01: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:
Edward Speyer 2013-04-18 17:45:12 +01:00
parent be358bddae
commit 961c2c0108
6 changed files with 20 additions and 18 deletions

View file

@ -28,12 +28,7 @@ final class ConduitAPI_releephwork_canpush_Method
protected function execute(ConduitAPIRequest $request) { protected function execute(ConduitAPIRequest $request) {
$releeph_project = id(new ReleephProject()) $releeph_project = id(new ReleephProject())
->loadOneWhere('phid = %s', $request->getValue('projectPHID')); ->loadOneWhere('phid = %s', $request->getValue('projectPHID'));
$user = $request->getUser();
if (!$releeph_project->getPushers()) { return $releeph_project->isAuthoritative($user);
return true;
} else {
$user = $request->getUser();
return $releeph_project->isPusher($user);
}
} }
} }

View file

@ -94,13 +94,22 @@ final class ReleephProject extends ReleephDAO
return $this->getDetail('pushers', array()); return $this->getDetail('pushers', array());
} }
public function isPusherPHID($phid) { public function isPusher(PhabricatorUser $user) {
$pusher_phids = $this->getDetail('pushers', array()); // TODO Deprecate this once `isPusher` is out of the Facebook codebase.
return in_array($phid, $pusher_phids); return $this->isAuthoritative($user);
} }
public function isPusher(PhabricatorUser $user) { public function isAuthoritative(PhabricatorUser $user) {
return $this->isPusherPHID($user->getPHID()); 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() { public function loadPhabricatorRepository() {

View file

@ -65,7 +65,7 @@ final class ReleephRequest extends ReleephDAO {
$found_pusher_want = false; $found_pusher_want = false;
foreach ($this->userIntents as $phid => $intent) { foreach ($this->userIntents as $phid => $intent) {
if ($project->isPusherPHID($phid)) { if ($project->isAuthoritativePHID($phid)) {
if ($intent == self::INTENT_PASS) { if ($intent == self::INTENT_PASS) {
return self::INTENT_PASS; return self::INTENT_PASS;
} }

View file

@ -187,7 +187,7 @@ final class ReleephBranchBoxView extends AphrontView {
$releeph_project = $br->loadReleephProject(); $releeph_project = $br->loadReleephProject();
if (!$releeph_project->getPushers() || if (!$releeph_project->getPushers() ||
$releeph_project->isPusher($this->user)) { $releeph_project->isAuthoritative($this->user)) {
$buttons[] = phutil_tag( $buttons[] = phutil_tag(
'a', 'a',

View file

@ -44,9 +44,7 @@ final class ReleephRequestIntentsView extends AphrontView {
$intents = $request->getUserIntents(); $intents = $request->getUserIntents();
foreach ($intents as $user_phid => $user_intent) { foreach ($intents as $user_phid => $user_intent) {
if ($user_intent == $render_intent) { if ($user_intent == $render_intent) {
$is_pusher = $project->isPusherPHID($user_phid); if ($project->isAuthoritativePHID($user_phid)) {
if ($is_pusher) {
$pusher_links[] = phutil_tag( $pusher_links[] = phutil_tag(
'span', 'span',
array( array(

View file

@ -225,7 +225,7 @@ final class ReleephRequestHeaderView extends AphrontView {
$right_buttons = array(); $right_buttons = array();
$user_phid = $this->user->getPHID(); $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; $is_requestor = $this->releephRequest->getRequestUserPHID() === $user_phid;
$current_intent = idx( $current_intent = idx(