mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-31 08:58:20 +01:00
When a user resigns from a commit they have authority over auditing projects for, write resign explicitly
Summary: For most actions (like "accept"), we write a row only if you aren't acting on behalf of anything else. This avoids cases like every accept causing two relationships: Some Project | Accept Some User | Accept For "Resign", we must always write the row. Break the logic out and handle it separately. Test Plan: Poked it locally, but let me know if this fixes things? Reviewers: 20after4, btrahan Reviewed By: 20after4 CC: aran Differential Revision: https://secure.phabricator.com/D2423
This commit is contained in:
parent
31142e6d0a
commit
eb9645e9b4
1 changed files with 24 additions and 12 deletions
|
@ -139,6 +139,30 @@ final class PhabricatorAuditCommentEditor {
|
||||||
$request->save();
|
$request->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if ($action == PhabricatorAuditActionConstants::RESIGN) {
|
||||||
|
// "Resign" has unusual rules for writing user rows, only affects the
|
||||||
|
// user row (never package/project rows), and always affects the user
|
||||||
|
// row (other actions don't, if they were able to affect a package/project
|
||||||
|
// row).
|
||||||
|
$user_request = null;
|
||||||
|
foreach ($requests as $request) {
|
||||||
|
if ($request->getAuditorPHID() == $user->getPHID()) {
|
||||||
|
$user_request = $request;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$user_request) {
|
||||||
|
$user_request = id(new PhabricatorRepositoryAuditRequest())
|
||||||
|
->setCommitPHID($commit->getPHID())
|
||||||
|
->setAuditorPHID($user->getPHID())
|
||||||
|
->setAuditReasons(array("Resigned"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_request
|
||||||
|
->setAuditStatus(PhabricatorAuditStatusConstants::RESIGNED)
|
||||||
|
->save();
|
||||||
|
|
||||||
|
$requests[] = $user_request;
|
||||||
} else {
|
} else {
|
||||||
$have_any_requests = false;
|
$have_any_requests = false;
|
||||||
foreach ($requests as $request) {
|
foreach ($requests as $request) {
|
||||||
|
@ -170,13 +194,6 @@ final class PhabricatorAuditCommentEditor {
|
||||||
$new_status = PhabricatorAuditStatusConstants::CONCERNED;
|
$new_status = PhabricatorAuditStatusConstants::CONCERNED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PhabricatorAuditActionConstants::RESIGN:
|
|
||||||
// NOTE: Resigning resigns ONLY your user request, not the requests
|
|
||||||
// of any projects or packages you are a member of.
|
|
||||||
if ($request_is_for_user) {
|
|
||||||
$new_status = PhabricatorAuditStatusConstants::RESIGNED;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown action '{$action}'!");
|
throw new Exception("Unknown action '{$action}'!");
|
||||||
}
|
}
|
||||||
|
@ -202,11 +219,6 @@ final class PhabricatorAuditCommentEditor {
|
||||||
case PhabricatorAuditActionConstants::CONCERN:
|
case PhabricatorAuditActionConstants::CONCERN:
|
||||||
$new_status = PhabricatorAuditStatusConstants::CONCERNED;
|
$new_status = PhabricatorAuditStatusConstants::CONCERNED;
|
||||||
break;
|
break;
|
||||||
case PhabricatorAuditActionConstants::RESIGN:
|
|
||||||
// If you're on an audit because of a package, we write an explicit
|
|
||||||
// resign row to remove it from your queue.
|
|
||||||
$new_status = PhabricatorAuditStatusConstants::RESIGNED;
|
|
||||||
break;
|
|
||||||
case PhabricatorAuditActionConstants::CLOSE:
|
case PhabricatorAuditActionConstants::CLOSE:
|
||||||
// Impossible to reach this block with 'close'.
|
// Impossible to reach this block with 'close'.
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Reference in a new issue