summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'extensions')
-rw-r--r--extensions/PhabBugz/lib/Feed.pm134
1 files changed, 0 insertions, 134 deletions
diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm
index f2a440bb1..2dbeef6a7 100644
--- a/extensions/PhabBugz/lib/Feed.pm
+++ b/extensions/PhabBugz/lib/Feed.pm
@@ -14,7 +14,6 @@ use IO::Async::Loop;
use List::Util qw(first);
use List::MoreUtils qw(any uniq);
use Moo;
-use Scalar::Util qw(blessed);
use Try::Tiny;
use Type::Params qw( compile );
use Type::Utils;
@@ -501,105 +500,6 @@ sub process_revision_change {
$attachment->update($timestamp);
}
- # REVIEWER STATUSES
-
- my (@accepted, @denied);
- foreach my $review (@{ $revision->reviews }) {
- push @accepted, $review->{user} if $review->{status} eq 'accepted';
- push @denied, $review->{user} if $review->{status} eq 'rejected';
- }
-
- my @accepted_user_ids = map { $_->bugzilla_user->id } grep { defined $_->bugzilla_user } @accepted;
- my @denied_user_ids = map { $_->bugzilla_user->id } grep { defined $_->bugzilla_user } @denied;
- my %reviewers_hash = map { $_->{user}->name => 1 } @{ $revision->reviews };
-
- foreach my $attachment (@attachments) {
- my ($attach_revision_id) = ($attachment->filename =~ PHAB_ATTACHMENT_PATTERN);
- next if $revision->id != $attach_revision_id;
-
- # Clear old accepted review flags if no longer accepted
- my (@denied_flags, @new_flags, @removed_flags, %accepted_done, $flag_type);
- foreach my $flag (@{ $attachment->flags }) {
- next if $flag->type->name ne 'review';
- $flag_type = $flag->type if $flag->type->is_active;
- next if $flag->status ne '+';
- if (any { $flag->setter->id == $_ } @denied_user_ids) {
- INFO('Denying review flag set by ' . $flag->setter->name);
- push(@denied_flags, { id => $flag->id, setter => $flag->setter, status => 'X' });
- }
- if (any { $flag->setter->id == $_ } @accepted_user_ids) {
- INFO('Skipping as review+ already set by ' . $flag->setter->name);
- $accepted_done{$flag->setter->id}++;
- }
- if (!any { $flag->setter->id == $_ } (@accepted_user_ids, @denied_user_ids)) {
- INFO('Clearing review+ flag set by ' . $flag->setter->name);
- push(@removed_flags, { id => $flag->id, setter => $flag->setter, status => 'X' });
- }
- }
-
- $flag_type ||= first { $_->name eq 'review' && $_->is_active } @{ $attachment->flag_types };
-
- die "Unable to find review flag!" unless $flag_type;
-
- # Create new flags
- foreach my $user_id (@accepted_user_ids) {
- next if $accepted_done{$user_id};
- my $user = Bugzilla::User->check({ id => $user_id, cache => 1 });
- INFO('Setting new review+ flag for ' . $user->name);
- push(@new_flags, { type_id => $flag_type->id, setter => $user, status => '+' });
- }
-
- # Process each flag change by updating the flag and adding a comment
- foreach my $flag_data (@new_flags) {
- my $comment = $flag_data->{setter}->name . " has approved the revision.";
- $self->add_flag_comment(
- {
- bug => $bug,
- attachment => $attachment,
- comment => $comment,
- user => $flag_data->{setter},
- old_flags => [],
- new_flags => [$flag_data],
- timestamp => $timestamp
- }
- );
- }
- foreach my $flag_data (@denied_flags) {
- my $comment = $flag_data->{setter}->name . " has requested changes to the revision.\n";
- $self->add_flag_comment(
- {
- bug => $bug,
- attachment => $attachment,
- comment => $comment,
- user => $flag_data->{setter},
- old_flags => [$flag_data],
- new_flags => [],
- timestamp => $timestamp
- }
- );
- }
- foreach my $flag_data (@removed_flags) {
- my $comment;
- if ( exists $reviewers_hash{ $flag_data->{setter}->name } ) {
- $comment = "Flag set by " . $flag_data->{setter}->name . " is no longer active.\n";
- }
- else {
- $comment = $flag_data->{setter}->name . " has been removed from the revision.\n";
- }
- $self->add_flag_comment(
- {
- bug => $bug,
- attachment => $attachment,
- comment => $comment,
- user => $flag_data->{setter},
- old_flags => [$flag_data],
- new_flags => [],
- timestamp => $timestamp
- }
- );
- }
- }
-
# FINISH UP
$bug->update($timestamp);
@@ -839,38 +739,4 @@ sub get_group_members {
);
}
-sub add_flag_comment {
- state $check = compile(
- $Invocant,
- Dict [
- bug => Bug,
- attachment => Attachment,
- comment => Str,
- user => User,
- old_flags => ArrayRef,
- new_flags => ArrayRef,
- timestamp => Str,
- ],
- );
- my ( $self, $params ) = $check->(@_);
- my ( $bug, $attachment, $comment, $user, $old_flags, $new_flags, $timestamp )
- = @$params{qw(bug attachment comment user old_flags new_flags timestamp)};
-
- # when this function returns, Bugzilla->user will return to its previous value.
- my $restore_prev_user = Bugzilla->set_user($user, scope_guard => 1);
-
- INFO("Flag comment: $comment");
- $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);
-}
-
1;