From 977dfb52f737e62cf67728fe95dccff1f0ef4739 Mon Sep 17 00:00:00 2001 From: Dylan Hardison Date: Wed, 27 Apr 2016 19:40:01 -0400 Subject: Bug 1256051 - Allow MozReview.attachments() to post mozreview-* tags without requiring editbugs --- extensions/MozReview/lib/WebService.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'extensions') diff --git a/extensions/MozReview/lib/WebService.pm b/extensions/MozReview/lib/WebService.pm index 947e65815..8f9d3215b 100644 --- a/extensions/MozReview/lib/WebService.pm +++ b/extensions/MozReview/lib/WebService.pm @@ -21,7 +21,7 @@ use Bugzilla::WebService::Constants; use Bugzilla::WebService::Util qw(extract_flags validate translate); use Bugzilla::Util qw(trim); -use List::MoreUtils qw(uniq); +use List::MoreUtils qw(uniq all); use List::Util qw(max); use Storable qw(dclone); @@ -62,12 +62,19 @@ sub attachments { if ($comment_tags) { ThrowUserError('comment_tag_disabled') unless Bugzilla->params->{comment_taggers_group}; - ThrowUserError('auth_failure', - { group => Bugzilla->params->{comment_taggers_group}, - action => 'update', - object => 'comment_tags' }) - unless $user->can_tag_comments; - $bug->set_all({ comment_tags => $comment_tags }); + + my $all_mozreview_tags = all { /^mozreview-?/i } @$comment_tags; + if ($all_mozreview_tags || $user->can_tag_comments) { + # there should be a method of User that does this. + local $user->{can_tag_comments} = 1; + $bug->set_all({ comment_tags => $comment_tags }); + } + else { + ThrowUserError('auth_failure', + { group => Bugzilla->params->{comment_taggers_group}, + action => 'update', + object => 'comment_tags' }) + } } foreach my $attachment (@$attachments) { -- cgit v1.2.3-24-g4f1b