From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- extensions/EditComments/lib/WebService.pm | 89 +++++++++++++++---------------- 1 file changed, 43 insertions(+), 46 deletions(-) (limited to 'extensions/EditComments/lib/WebService.pm') diff --git a/extensions/EditComments/lib/WebService.pm b/extensions/EditComments/lib/WebService.pm index 6969ca742..97e40b8b6 100644 --- a/extensions/EditComments/lib/WebService.pm +++ b/extensions/EditComments/lib/WebService.pm @@ -18,64 +18,61 @@ use Bugzilla::Util qw(trim); use Bugzilla::WebService::Util qw(validate); use constant PUBLIC_METHODS => qw( - comments + comments ); sub comments { - my ($self, $params) = validate(@_, 'comment_ids'); - my $dbh = Bugzilla->switch_to_shadow_db(); - my $user = Bugzilla->user; - - if (!defined $params->{comment_ids}) { - ThrowCodeError('param_required', - { function => 'Bug.comments', - param => 'comment_ids' }); + my ($self, $params) = validate(@_, 'comment_ids'); + my $dbh = Bugzilla->switch_to_shadow_db(); + my $user = Bugzilla->user; + + if (!defined $params->{comment_ids}) { + ThrowCodeError('param_required', + {function => 'Bug.comments', param => 'comment_ids'}); + } + + my @ids = map { trim($_) } @{$params->{comment_ids} || []}; + my $comment_data = Bugzilla::Comment->new_from_list(\@ids); + + # See if we were passed any invalid comment ids. + my %got_ids = map { $_->id => 1 } @$comment_data; + foreach my $comment_id (@ids) { + if (!$got_ids{$comment_id}) { + ThrowUserError('comment_id_invalid', {id => $comment_id}); } + } - my @ids = map { trim($_) } @{ $params->{comment_ids} || [] }; - my $comment_data = Bugzilla::Comment->new_from_list(\@ids); + # Now make sure that we can see all the associated bugs. + my %got_bug_ids = map { $_->bug_id => 1 } @$comment_data; + $user->visible_bugs([keys %got_bug_ids]); # preload cache for visibility check + Bugzilla::Bug->check($_) foreach (keys %got_bug_ids); - # See if we were passed any invalid comment ids. - my %got_ids = map { $_->id => 1 } @$comment_data; - foreach my $comment_id (@ids) { - if (!$got_ids{$comment_id}) { - ThrowUserError('comment_id_invalid', { id => $comment_id }); - } + my %comments; + foreach my $comment (@$comment_data) { + if ($comment->is_private && !$user->is_insider) { + ThrowUserError('comment_is_private', {id => $comment->id}); } + $comments{$comment->id} = $comment->body; + } - # Now make sure that we can see all the associated bugs. - my %got_bug_ids = map { $_->bug_id => 1 } @$comment_data; - $user->visible_bugs([ keys %got_bug_ids ]); # preload cache for visibility check - Bugzilla::Bug->check($_) foreach (keys %got_bug_ids); - - my %comments; - foreach my $comment (@$comment_data) { - if ($comment->is_private && !$user->is_insider) { - ThrowUserError('comment_is_private', { id => $comment->id }); - } - $comments{$comment->id} = $comment->body; - } - - return { comments => \%comments }; + return {comments => \%comments}; } sub rest_resources { - return [ - qr{^/editcomments/comment/(\d+)$}, { - GET => { - method => 'comments', - params => sub { - return { comment_ids => $_[0] }; - }, - }, + return [ + qr{^/editcomments/comment/(\d+)$}, + { + GET => { + method => 'comments', + params => sub { + return {comment_ids => $_[0]}; }, - qr{^/editcomments/comment$}, { - GET => { - method => 'comments', - }, - }, - ]; -}; + }, + }, + qr{^/editcomments/comment$}, + {GET => {method => 'comments',},}, + ]; +} 1; -- cgit v1.2.3-24-g4f1b