mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
When a user makes an audit comment, retroactively trigger an audit
Summary: If a user comments on a commit but they don't currently have any audits they're authoritative on, create a new one. This makes it easier to handle other things more consistently, like figuring out the overall audit status of a commit and who should get emails. Test Plan: Made comments on commits I had authority on and did not have authority on. Reviewers: btrahan, jungejason Reviewed By: jungejason CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1697
This commit is contained in:
parent
25fade5008
commit
cfbec38fbe
2 changed files with 22 additions and 6 deletions
|
@ -61,19 +61,34 @@ final class PhabricatorAuditCommentEditor {
|
|||
|
||||
// Status may be empty for updates which don't affect status, like
|
||||
// "comment".
|
||||
if ($status) {
|
||||
foreach ($relationships as $relationship) {
|
||||
if (empty($audit_phids[$relationship->getPackagePHID()])) {
|
||||
continue;
|
||||
}
|
||||
$have_any_relationship = false;
|
||||
foreach ($relationships as $relationship) {
|
||||
if (empty($audit_phids[$relationship->getPackagePHID()])) {
|
||||
continue;
|
||||
}
|
||||
$have_any_relationship = true;
|
||||
if ($status) {
|
||||
$relationship->setAuditStatus($status);
|
||||
$relationship->save();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$have_any_relationship) {
|
||||
// If the user has no current authority over any audit trigger, make a
|
||||
// new one to represent their audit state.
|
||||
$relationship = id(new PhabricatorOwnersPackageCommitRelationship())
|
||||
->setCommitPHID($commit->getPHID())
|
||||
->setPackagePHID($user->getPHID())
|
||||
->setAuditStatus(
|
||||
$status
|
||||
? $status
|
||||
: PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED)
|
||||
->setAuditReasons(array("Voluntary Participant"))
|
||||
->save();
|
||||
}
|
||||
|
||||
$this->publishFeedStory($comment, array_keys($audit_phids));
|
||||
PhabricatorSearchCommitIndexer::indexCommit($commit);
|
||||
|
||||
// TODO: Email.
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
phutil_require_module('phabricator', 'applications/audit/constants/action');
|
||||
phutil_require_module('phabricator', 'applications/feed/constants/story');
|
||||
phutil_require_module('phabricator', 'applications/feed/publisher');
|
||||
phutil_require_module('phabricator', 'applications/audit/constants/status');
|
||||
phutil_require_module('phabricator', 'applications/owners/storage/owner');
|
||||
phutil_require_module('phabricator', 'applications/owners/storage/package');
|
||||
phutil_require_module('phabricator', 'applications/owners/storage/packagecommitrelationship');
|
||||
|
|
Loading…
Reference in a new issue