summaryrefslogtreecommitdiffstats
path: root/extensions/PhabBugz/lib/WebService.pm
diff options
context:
space:
mode:
authordklawren <dklawren@users.noreply.github.com>2017-09-11 23:14:28 +0200
committerDavid Walsh <davidwalsh83@gmail.com>2017-09-11 23:14:28 +0200
commit43d5609877e8690fe5bba5243d4642014fb2ba06 (patch)
tree57add7bbceaae06c0741b350f7c55706a311754f /extensions/PhabBugz/lib/WebService.pm
parentce38f8be741a8b618dfac9d2f6f166a6e3954e45 (diff)
downloadbugzilla-43d5609877e8690fe5bba5243d4642014fb2ba06.tar.gz
bugzilla-43d5609877e8690fe5bba5243d4642014fb2ba06.tar.xz
Bug 1397927 - Add comment to bug when a revision is accepted/denied with the users real names (#233)
Bug 1397927 - Add comment to bug when a revision is accepted/denied with the users real names * - Bug fixes * Wording changes.
Diffstat (limited to 'extensions/PhabBugz/lib/WebService.pm')
-rw-r--r--extensions/PhabBugz/lib/WebService.pm38
1 files changed, 31 insertions, 7 deletions
diff --git a/extensions/PhabBugz/lib/WebService.pm b/extensions/PhabBugz/lib/WebService.pm
index e09a72036..6ef5a8b5c 100644
--- a/extensions/PhabBugz/lib/WebService.pm
+++ b/extensions/PhabBugz/lib/WebService.pm
@@ -164,6 +164,11 @@ sub update_reviewer_statuses {
|| ThrowCodeError('param_required', { param => 'accepted_users' });
$accepted_user_ids = [ split(':', $accepted_user_ids) ];
+ my $denied_user_ids = $params->{denied_users};
+ defined $denied_user_ids
+ || ThrowCodeError('param_required', { param => 'denied_users' });
+ $denied_user_ids = [ split(':', $denied_user_ids) ];
+
my $bug = Bugzilla::Bug->check($bug_id);
my @attachments =
@@ -179,17 +184,16 @@ sub update_reviewer_statuses {
my ($curr_revision_id) = ($attachment->filename =~ PHAB_ATTACHMENT_PATTERN);
next if $revision_id != $curr_revision_id;
- # Clear old flags if no longer accepted or a previous
- # acceptor is not in the new list.
- my (@old_flags, @new_flags, %accepted_done, $flag_type);
+ # Clear old flags if no longer accepted
+ my (@old_flags, @new_flags, %accepted_done, %denied_done, $flag_type);
foreach my $flag (@{ $attachment->flags }) {
next if $flag->type->name ne 'review';
$flag_type = $flag->type;
- unless (any { $flag->setter->id == $_ } @$accepted_user_ids) {
- push(@old_flags, { id => $flag->id, status => 'X' });
+ if (any { $flag->setter->id == $_ } @$denied_user_ids) {
+ push(@old_flags, { id => $flag->id, setter => $flag->setter, status => 'X' });
}
- else {
- $accepted_done{$flag->setter->id}++; # so we do not set it again as new
+ if (any { $flag->setter->id == $_ } @$accepted_user_ids) {
+ $accepted_done{$flag->setter->id}++;
}
}
@@ -202,8 +206,28 @@ sub update_reviewer_statuses {
push(@new_flags, { type_id => $flag_type->id, setter => $user, status => '+' });
}
+ # Also add comment to for attachment update showing the user's name
+ # that changed the revision.
+ my $comment;
+ foreach my $flag_data (@new_flags) {
+ $comment .= $flag_data->{setter}->name . " has approved the revision.\n";
+ }
+ foreach my $flag_data (@old_flags) {
+ $comment .= $flag_data->{setter}->name . " has requested changes to the revision.\n";
+ }
+
+ if ($comment) {
+ $comment .= "\n" . Bugzilla->params->{phabricator_base_uri} . "D" . $revision_id;
+ $bug->add_comment($comment, {
+ isprivate => $attachment->isprivate,
+ type => CMT_ATTACHMENT_UPDATED,
+ extra_data => $attachment->id
+ });
+ }
+
$attachment->set_flags(\@old_flags, \@new_flags);
$attachment->update($timestamp);
+ $bug->update($timestamp) if $comment;
push(@updated_attach_ids, $attachment->id);
}