1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +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:
epriestley 2012-02-27 09:53:49 -08:00
parent 25fade5008
commit cfbec38fbe
2 changed files with 22 additions and 6 deletions

View file

@ -61,19 +61,34 @@ final class PhabricatorAuditCommentEditor {
// Status may be empty for updates which don't affect status, like // Status may be empty for updates which don't affect status, like
// "comment". // "comment".
if ($status) { $have_any_relationship = false;
foreach ($relationships as $relationship) { foreach ($relationships as $relationship) {
if (empty($audit_phids[$relationship->getPackagePHID()])) { if (empty($audit_phids[$relationship->getPackagePHID()])) {
continue; continue;
} }
$have_any_relationship = true;
if ($status) {
$relationship->setAuditStatus($status); $relationship->setAuditStatus($status);
$relationship->save(); $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)); $this->publishFeedStory($comment, array_keys($audit_phids));
PhabricatorSearchCommitIndexer::indexCommit($commit); PhabricatorSearchCommitIndexer::indexCommit($commit);
// TODO: Email. // TODO: Email.
} }

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'applications/audit/constants/action'); phutil_require_module('phabricator', 'applications/audit/constants/action');
phutil_require_module('phabricator', 'applications/feed/constants/story'); phutil_require_module('phabricator', 'applications/feed/constants/story');
phutil_require_module('phabricator', 'applications/feed/publisher'); 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/owner');
phutil_require_module('phabricator', 'applications/owners/storage/package'); phutil_require_module('phabricator', 'applications/owners/storage/package');
phutil_require_module('phabricator', 'applications/owners/storage/packagecommitrelationship'); phutil_require_module('phabricator', 'applications/owners/storage/packagecommitrelationship');