summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authordklawren <dklawren@users.noreply.github.com>2018-09-07 12:04:50 +0200
committerDylan William Hardison <dylan@hardison.net>2018-09-07 12:04:50 +0200
commit2e6e3e13587ee526ba94faabd5551e67508518f5 (patch)
treed54e6a7bf25c0545ef23e4854f70d5a55589b2a7 /extensions
parenta68b0d94e176d37e1381f38f235f760ca0a1001d (diff)
downloadbugzilla-2e6e3e13587ee526ba94faabd5551e67508518f5.tar.gz
bugzilla-2e6e3e13587ee526ba94faabd5551e67508518f5.tar.xz
Bug 1488292 - Remove MozReview extension from BMO code tree as MozReview is being decommissioned
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BMO/lib/Data.pm21
-rw-r--r--extensions/MozReview/Config.pm16
-rw-r--r--extensions/MozReview/Extension.pm132
-rwxr-xr-xextensions/MozReview/bin/add-mozreview-children.pl257
-rw-r--r--extensions/MozReview/lib/Config.pm55
-rw-r--r--extensions/MozReview/lib/WebService.pm209
-rw-r--r--extensions/MozReview/template/en/default/admin/params/mozreview.html.tmpl20
-rw-r--r--extensions/MozReview/template/en/default/hook/attachment/create-before_form.html.tmpl17
-rw-r--r--extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl16
-rw-r--r--extensions/MozReview/template/en/default/hook/bug/edit-after_bug_data.html.tmpl35
-rw-r--r--extensions/MozReview/template/en/default/hook/bug/show-header-end.html.tmpl13
-rw-r--r--extensions/MozReview/template/en/default/hook/bug_modal/edit-module.html.tmpl21
-rw-r--r--extensions/MozReview/template/en/default/hook/bug_modal/header-end.html.tmpl13
-rw-r--r--extensions/MozReview/template/en/default/hook/global/header-start.html.tmpl11
-rw-r--r--extensions/MozReview/template/en/default/hook/global/user-error-errors.html.tmpl15
-rw-r--r--extensions/MozReview/template/en/default/moz_review/header.html.tmpl10
-rw-r--r--extensions/MozReview/template/en/default/moz_review/table.html.tmpl28
-rw-r--r--extensions/MozReview/web/js/mozreview.js134
-rw-r--r--extensions/MozReview/web/style/attachment.css13
-rw-r--r--extensions/MozReview/web/style/mozreview.css79
-rw-r--r--extensions/Push/lib/Connector/ReviewBoard.pm178
-rw-r--r--extensions/Push/t/ReviewBoard.t225
22 files changed, 0 insertions, 1518 deletions
diff --git a/extensions/BMO/lib/Data.pm b/extensions/BMO/lib/Data.pm
index b444d6a24..dc6a3894f 100644
--- a/extensions/BMO/lib/Data.pm
+++ b/extensions/BMO/lib/Data.pm
@@ -27,21 +27,6 @@ our @EXPORT = qw( $cf_visible_in_products
# will result in the user being redirected to that URL when viewing the
# attachment.
-my $mozreview_url_re = qr{
- # begins with mozreview hostname
- ^
- https?://reviewboard(?:-dev)?\.(?:allizom|mozilla)\.org
-
- # followed by a review path
- /r/\d+
-
- # ends with optional suffix
- (?: /
- | /diff/\#index_header
- )?
- $
-}ix;
-
sub phabricator_url_re {
my $phab_uri = Bugzilla->params->{phabricator_base_uri} || 'https://example.com';
return qr/^\Q${phab_uri}\ED\d+$/i;
@@ -54,12 +39,6 @@ our %autodetect_attach_urls = (
content_type => 'text/x-github-pull-request',
can_review => 1,
},
- reviewboard => {
- title => 'MozReview',
- regex => $mozreview_url_re,
- content_type => 'text/x-review-board-request',
- can_review => 1,
- },
Phabricator => {
title => 'Phabricator',
regex => \&phabricator_url_re,
diff --git a/extensions/MozReview/Config.pm b/extensions/MozReview/Config.pm
deleted file mode 100644
index 34d98907c..000000000
--- a/extensions/MozReview/Config.pm
+++ /dev/null
@@ -1,16 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-package Bugzilla::Extension::MozReview;
-
-use 5.10.1;
-use strict;
-use warnings;
-
-use constant NAME => 'MozReview';
-
-__PACKAGE__->NAME;
diff --git a/extensions/MozReview/Extension.pm b/extensions/MozReview/Extension.pm
deleted file mode 100644
index 907f12e56..000000000
--- a/extensions/MozReview/Extension.pm
+++ /dev/null
@@ -1,132 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-package Bugzilla::Extension::MozReview;
-
-use 5.10.1;
-use strict;
-use warnings;
-use parent qw(Bugzilla::Extension);
-
-use Bugzilla::Attachment;
-use Bugzilla::Error;
-use Bugzilla::Extension::MozReview::WebService;
-use List::MoreUtils qw( any );
-
-our $VERSION = '0.01';
-
-my @METHOD_WHITELIST = (
- 'User.get',
- 'User.login',
- 'User.valid_login',
- 'Bug.add_comment',
- 'Bug.add_attachment',
- 'Bug.attachments',
- 'Bug.get',
- 'Bug.update_attachment',
-);
-
-BEGIN {
- package Bugzilla::User::APIKey;
-
- sub is_mozreview {
- my ($self) = @_;
- my $mozreview_app_id = Bugzilla->params->{mozreview_app_id};
- return 0 unless $mozreview_app_id;
-
- return 1 if $self->app_id && $self->app_id eq $mozreview_app_id;
- }
-}
-
-sub template_before_process {
- my ($self, $args) = @_;
- my $file = $args->{'file'};
- my $vars = $args->{'vars'};
-
- return unless (($file =~ /bug\/(show-header|edit).html.tmpl$/ ||
- $file =~ /bug_modal\/(header|edit).html.tmpl$/ ||
- $file eq 'attachment/create.html.tmpl') &&
- Bugzilla->params->{mozreview_base_url});
-
- my $bug = exists $vars->{'bugs'} ? $vars->{'bugs'}[0] : $vars->{'bug'};
-
- if ($bug) {
- if ($file eq 'attachment/create.html.tmpl') {
- if ($bug->product eq 'Core' || $bug->product eq 'Firefox' ||
- $bug->product eq 'Firefox for Android') {
- $vars->{'mozreview_enabled'} = 1;
- }
- } else {
- my $has_mozreview = 0;
- my $attachments = Bugzilla::Attachment->get_attachments_by_bug($bug);
-
- foreach my $attachment (@$attachments) {
- if ($attachment->contenttype eq 'text/x-review-board-request'
- && !$attachment->isobsolete) {
- $has_mozreview = 1;
- last;
- }
- }
-
- if ($has_mozreview) {
- $vars->{'mozreview'} = 1;
- }
- }
- }
-}
-
-sub auth_delegation_confirm {
- my ($self, $args) = @_;
- my $mozreview_callback_url = Bugzilla->params->{mozreview_auth_callback_url};
- my $mozreview_app_id = Bugzilla->params->{mozreview_app_id};
-
- return unless $mozreview_callback_url;
- return unless $mozreview_app_id;
-
- if (index($args->{callback}, $mozreview_callback_url) == 0 && $args->{app_id} eq $mozreview_app_id) {
- ${$args->{skip_confirmation}} = 1;
- }
-}
-
-sub config_add_panels {
- my ($self, $args) = @_;
- my $modules = $args->{panel_modules};
- $modules->{MozReview} = "Bugzilla::Extension::MozReview::Config";
-}
-
-sub webservice {
- my ($self, $args) = @_;
- my $dispatch = $args->{dispatch};
- $dispatch->{MozReview} = "Bugzilla::Extension::MozReview::WebService";
-}
-
-sub webservice_before_call {
- my ($self, $args) = @_;
- my ($method, $full_method) = ($args->{method}, $args->{full_method});
- my $mozreview_app_id = Bugzilla->params->{mozreview_app_id} // '';
- my $user = Bugzilla->user;
- my $getter = eval { $user->authorizer->successful_info_getter() } or return;
- my $app_id = $getter->can("app_id") ? $getter->app_id // '' : '';
-
- $full_method =~ s/^Bugzilla::Extension::(\w+)::WebService\./$1./;
-
- my $is_mozreview_method = $full_method =~ /^MozReview\./;
-
- if ($is_mozreview_method && (!$mozreview_app_id || !$app_id || $mozreview_app_id ne $app_id)) {
- ThrowUserError('forbidden_method', { method => $full_method });
- }
-
- return unless $mozreview_app_id && $app_id;
-
- if ($app_id eq $mozreview_app_id && !$is_mozreview_method) {
- unless (any { $full_method eq $_ } @METHOD_WHITELIST) {
- ThrowUserError('forbidden_method', { method => $full_method });
- }
- }
-}
-
-__PACKAGE__->NAME;
diff --git a/extensions/MozReview/bin/add-mozreview-children.pl b/extensions/MozReview/bin/add-mozreview-children.pl
deleted file mode 100755
index 9faa923fa..000000000
--- a/extensions/MozReview/bin/add-mozreview-children.pl
+++ /dev/null
@@ -1,257 +0,0 @@
-#!/usr/bin/perl
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-# This script obsoletes attachments containing URLs to MozReview parent
-# review requests and adds attachments, with review flags, for MozReview
-# child (commit) review requests to match the new scheme.
-
-use strict;
-use warnings;
-use 5.10.1;
-
-use lib qw(. lib local/lib/perl5);
-
-BEGIN {
- use Bugzilla;
- Bugzilla->extensions;
-}
-use Bugzilla::Constants qw( USAGE_MODE_CMDLINE );
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-use Bugzilla::Attachment;
-use Bugzilla::Bug;
-use Bugzilla::Constants;
-use Bugzilla::Flag;
-use Bugzilla::FlagType;
-use JSON;
-use LWP::Simple qw( get $ua );
-
-$Bugzilla::Flag::disable_flagmail = 1;
-
-if (my $proxy = Bugzilla->params->{proxy_url}) {
- $ua->proxy('https', $proxy);
-}
-
-my $MOZREVIEW_MIMETYPE = 'text/x-review-board-request';
-
-# Disable the "cannot ask for review" so we can reassign their flags to
-# the new attachments.
-Bugzilla->params->{max_reviewer_last_seen} = 0;
-
-my $rb_host = shift or die "syntax: $0 review-board-url\n";
-$rb_host =~ s#/$##;
-
-sub rr_url {
- my ($rrid) = @_;
- return $rb_host . "/r/" . $rrid . "/";
-}
-
-sub set_review_flag {
- my ($child_attach, $flag_type, $flag_status, $reviewer, $setter) = @_;
-
- my %params = (
- type_id => $flag_type->id,
- status => $flag_status
- );
-
- if ($flag_status eq "?") {
- $params{'requestee'} = $reviewer->login;
- $params{'setter'} = $setter;
- } else {
- $params{'setter'} = $reviewer;
- }
-
- return Bugzilla::Flag->set_flag($child_attach, \%params);
-}
-
-my $dbh = Bugzilla->dbh;
-
-my $bugs_query = "SELECT distinct bug_id FROM attachments WHERE mimetype='text/x-review-board-request' AND isobsolete=0";
-my $bug_ids = $dbh->selectcol_arrayref($bugs_query);
-my $total_bugs = scalar @$bug_ids;
-$total_bugs or die "No bugs were found.\n";
-my $bug_count = 0;
-
-print <<EOF;
-About to convert MozReview attachments for $total_bugs bugs.
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
-getc();
-
-foreach my $bug_id (@$bug_ids) {
- $dbh->bz_start_transaction();
- my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
- my $bug_changed = 0;
- my $bug = Bugzilla::Bug->new($bug_id);
- print "Bug " . $bug->id . " (" . ++$bug_count . "/" . $total_bugs . ")\n";
-
- my $url = $rb_host . "/api/extensions/mozreview.extension.MozReviewExtension/summary/?bug=" . $bug->id;
- print " Fetching reviews from $url...\n";
- my $body = get($url);
- die "Error fetching review requests for bug " . $bug->id
- unless defined $body;
-
- my $data = from_json($body);
- my $summaries = $data->{"review_request_summaries"};
- my $attachments = Bugzilla::Attachment->get_attachments_by_bug($bug);
- my %attach_map;
-
- my $flag_types = Bugzilla::FlagType::match({
- 'target_type' => 'attachment',
- 'product_id' => $bug->product_id,
- 'component_id' => $bug->component_id,
- 'is_active' => 1});
- my $flag_type;
-
- foreach my $ft (@$flag_types) {
- if ($ft->is_active && $ft->name eq "review") {
- $flag_type = $ft;
- last;
- }
- }
-
- if (!defined($flag_type)) {
- print " Couldn't find flag type for attachments on this bug!\n";
- $dbh->bz_rollback_transaction();
- next;
- }
-
- foreach my $attachment (@$attachments) {
- next if ($attachment->isobsolete
- || $attachment->contenttype ne $MOZREVIEW_MIMETYPE);
-
- print " Attachment " . $attachment->id . ": " . $attachment->data . "\n";
- my ($rrid) = $attachment->data =~ m#/r/(\d+)/?$#;
- if (!defined($rrid)) {
- print " Malformed or missing reviewboard URL\n";
- next;
- }
-
- $attach_map{$attachment->data} = $attachment;
- }
-
- foreach my $summary (@$summaries) {
- my $parent = $summary->{"parent"};
- my $attacher = Bugzilla::User->new({ id => $parent->{"submitter_bmo_id"},
- cache => 1 });
- Bugzilla->set_user($attacher);
- print " Parent review request " . $parent->{"id"} . "\n";
-
- # %parent_flags is used to keep track of review flags related to
- # reviewers. It maps requestee => status if status is "?" or
- # setter => status otherwise.
- my %parent_flags;
-
- my $parent_url = rr_url($parent->{"id"});
- my $parent_attach = $attach_map{$parent_url};
- if (defined($parent_attach)) {
- print " Parent attachment has ID " . $parent_attach->id . ". Obsoleting it.\n";
- foreach my $flag (@{ $parent_attach->flags }) {
- if ($flag->type->name eq "review") {
- if ($flag->status eq "?") {
- $parent_flags{$flag->requestee->id} = $flag;
- } else {
- $parent_flags{$flag->setter->id} = $flag;
- }
- }
- }
- $parent_attach->set_is_obsolete(1);
- $parent_attach->update($timestamp);
- print " Posting comment.\n";
- $bug->add_comment('',
- { isprivate => 0,
- type => CMT_ATTACHMENT_UPDATED,
- extra_data => $parent_attach->id });
- $bug_changed = 1;
- } else {
- print " Parent attachment not found.\n";
- }
-
- my @children = @{ $summary->{"children"} };
- foreach my $child (@children) {
- print " Child review request " . $child->{"id"} . "\n";
- my $child_url = rr_url($child->{"id"});
- my $child_attach = $attach_map{$child_url};
- if (defined($child_attach)) {
- print " Found attachment.\n";
- next;
- }
-
- print " No attachment found for child " . $child_url . "\n";
- my %child_attach_params = (
- bug => $bug,
- data => $rb_host . "/r/" . $child->{"id"} . "/",
- description => "MozReview Request: " . $child->{"summary"},
- filename => "reviewboard-" . $child->{"id"} . "-url.txt",
- mimetype => $MOZREVIEW_MIMETYPE,
- );
- $child_attach = Bugzilla::Attachment->create(\%child_attach_params);
- print " New attachment id: " . $child_attach->id . "\n";
- $bug_changed = 1;
-
- # Set flags. If there was a parent, check it for flags by the
- # requestee. Otherwise, set an r? flag.
-
- # Preserve the original flag hash since we need to modify it for
- # every child to find extra reviewers (see below the 'foreach').
- my %tmp_parent_flags = %parent_flags;
-
- foreach my $reviewer_id (@{ $child->{"reviewers_bmo_ids"} }) {
- my $reviewer = Bugzilla::User->new({ id => $reviewer_id,
- cache => 1 });
- print " Reviewer " . $reviewer->login . " (" . $reviewer->id . ")\n";
- $reviewer->settings->{block_reviews}->{value} = 'off';
- my $flag = $tmp_parent_flags{$reviewer->id};
- if (defined($flag)) {
- print " Flag for reviewer " . $reviewer->id . ": " . $flag->status . "\n";
-
- set_review_flag($child_attach, $flag_type, $flag->status,
- $reviewer, $attacher);
- delete $tmp_parent_flags{$reviewer->id};
- } else {
- # No flag on the parent; this probably means the reviewer
- # canceled the review, so don't set r?.
- print " No review flag for reviewer " . $reviewer->id . "\n";
- }
- }
-
- # Preserve flags that were set directly on the attachment
- # from reviewers not listed in the review request.
- foreach my $extra_reviewer_id (keys %tmp_parent_flags) {
- my $extra_reviewer = Bugzilla::User->new({
- id => $extra_reviewer_id,
- cache => 1
- });
- my $flag = $tmp_parent_flags{$extra_reviewer_id};
- print " Extra flag set for reviewer " . $extra_reviewer->login . "\n";
- set_review_flag($child_attach, $flag->type, $flag->status,
- $extra_reviewer, $flag->setter);
- }
-
- $child_attach->update($timestamp);
- print " Posting comment.\n";
- $bug->add_comment('',
- { isprivate => 0,
- type => CMT_ATTACHMENT_CREATED,
- extra_data => $child_attach->id });
- }
- }
-
- if ($bug_changed) {
- print " Updating bug.\n";
- $bug->update($timestamp);
- $dbh->do("UPDATE bugs SET lastdiffed = ?, delta_ts = ? WHERE bug_id = ?",
- undef, $timestamp, $timestamp, $bug_id);
- }
- $dbh->bz_commit_transaction();
- Bugzilla->memcached->clear_all();
-}
-
-print "Done.\n";
diff --git a/extensions/MozReview/lib/Config.pm b/extensions/MozReview/lib/Config.pm
deleted file mode 100644
index e0d6377d8..000000000
--- a/extensions/MozReview/lib/Config.pm
+++ /dev/null
@@ -1,55 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-package Bugzilla::Extension::MozReview::Config;
-
-use 5.10.1;
-use strict;
-use warnings;
-
-use Bugzilla::Config::Common;
-
-our $sortkey = 1300;
-
-sub get_param_list {
- my ($class) = @_;
-
- my @params = (
- {
- name => 'mozreview_base_url',
- type => 't',
- default => '',
- checker => \&check_urlbase
- },
- {
- name => 'mozreview_auth_callback_url',
- type => 't',
- default => '',
- checker => sub {
- my ($url) = (@_);
-
- return 'must be an HTTP/HTTPS absolute URL' unless $url =~ m{^https?://};
- return '';
- }
- },
- {
- name => 'mozreview_app_id',
- type => 't',
- default => '',
- checker => sub {
- my ($app_id) = (@_);
-
- return 'must be a hex number' unless $app_id =~ /^[[:xdigit:]]+$/;
- return '';
- },
- },
- );
-
- return @params;
-}
-
-1;
diff --git a/extensions/MozReview/lib/WebService.pm b/extensions/MozReview/lib/WebService.pm
deleted file mode 100644
index c6916d1fa..000000000
--- a/extensions/MozReview/lib/WebService.pm
+++ /dev/null
@@ -1,209 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-package Bugzilla::Extension::MozReview::WebService;
-
-use 5.10.1;
-use strict;
-use warnings;
-
-use base qw(Bugzilla::WebService);
-
-use Bugzilla::Attachment;
-use Bugzilla::Bug;
-use Bugzilla::Comment;
-use Bugzilla::Constants;
-use Bugzilla::Error;
-use Bugzilla::WebService::Constants;
-use Bugzilla::WebService::Util qw(extract_flags validate translate);
-use Bugzilla::Util qw(trim);
-
-use List::MoreUtils qw(uniq all);
-use List::Util qw(max);
-use Storable qw(dclone);
-
-use constant PUBLIC_METHODS => qw( attachments );
-
-BEGIN {
- *_attachment_to_hash = \&Bugzilla::WebService::Bug::_attachment_to_hash;
- *_flag_to_hash = \&Bugzilla::WebService::Bug::_flag_to_hash;
-}
-
-sub attachments {
- my ($self, $params) = validate(@_, 'attachments');
- my $dbh = Bugzilla->dbh;
-
- # BMO: Don't allow updating of bugs if disabled
- if (Bugzilla->params->{disable_bug_updates}) {
- ThrowErrorPage('bug/process/updates-disabled.html.tmpl',
- 'Bug updates are currently disabled.');
- }
-
- my $user = Bugzilla->login(LOGIN_REQUIRED);
-
- ThrowCodeError('param_required', { param => 'attachments' })
- unless defined $params->{attachments};
-
- my $bug = Bugzilla::Bug->check($params->{bug_id});
-
- ThrowUserError("product_edit_denied", { product => $bug->product })
- unless $user->can_edit_product($bug->product_id);
-
- my (@modified, @created);
- $dbh->bz_start_transaction();
- my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-
- my $comment_tags = $params->{comment_tags};
- my $attachments = $params->{attachments};
-
- if ($comment_tags) {
- ThrowUserError('comment_tag_disabled')
- unless Bugzilla->params->{comment_taggers_group};
-
- 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) {
- my $flags = delete $attachment->{flags};
- my $attachment_id = delete $attachment->{attachment_id};
- my $comment = delete $attachment->{comment};
- my $attachment_obj;
-
- if ($attachment_id) {
- $attachment_obj = Bugzilla::Attachment->check({ id => $attachment_id });
- ThrowUserError("mozreview_attachment_bug_mismatch", { bug => $bug, attachment => $attachment_obj })
- if $attachment_obj->bug_id != $bug->id;
-
- # HACK: preload same bug object.
- $attachment_obj->{bug} = $bug;
-
- $attachment = translate($attachment, Bugzilla::WebService::Bug::ATTACHMENT_MAPPED_SETTERS);
-
- my ($update_flags, $new_flags) = $flags
- ? extract_flags($flags, $bug, $attachment_obj)
- : ([], []);
- if ($attachment_obj->validate_can_edit) {
- $attachment_obj->set_all($attachment);
- $attachment_obj->set_flags($update_flags, $new_flags) if $flags;
- }
- elsif (scalar @$update_flags && !scalar(@$new_flags) && !scalar keys %$attachment) {
- # Requestees can set flags targetted to them, even if they cannot
- # edit the attachment. Flag setters can edit their own flags too.
- my %flag_list = map { $_->{id} => $_ } @$update_flags;
- my $flag_objs = Bugzilla::Flag->new_from_list([ keys %flag_list ]);
- my @editable_flags;
- foreach my $flag_obj (@$flag_objs) {
- if ($flag_obj->setter_id == $user->id
- || ($flag_obj->requestee_id && $flag_obj->requestee_id == $user->id))
- {
- push(@editable_flags, $flag_list{$flag_obj->id});
- }
- }
- if (!scalar @editable_flags) {
- ThrowUserError('illegal_attachment_edit', { attach_id => $attachment_obj->id });
- }
- $attachment_obj->set_flags(\@editable_flags, []);
- }
- else {
- ThrowUserError('illegal_attachment_edit', { attach_id => $attachment_obj->id });
- }
-
- my $changes = $attachment_obj->update($timestamp);
-
- if (my $comment_text = trim($comment)) {
- $attachment_obj->bug->add_comment($comment_text,
- { isprivate => $attachment_obj->isprivate,
- type => CMT_ATTACHMENT_UPDATED,
- extra_data => $attachment_obj->id });
- }
-
- $changes = translate($changes, Bugzilla::WebService::Bug::ATTACHMENT_MAPPED_RETURNS);
-
- my %hash = (
- id => $self->type('int', $attachment_obj->id),
- last_change_time => $self->type('dateTime', $attachment_obj->modification_time),
- changes => {},
- );
-
- foreach my $field (keys %$changes) {
- my $change = $changes->{$field};
-
- # We normalize undef to an empty string, so that the API
- # stays consistent for things like Deadline that can become
- # empty.
- $hash{changes}->{$field} = {
- removed => $self->type('string', $change->[0] // ''),
- added => $self->type('string', $change->[1] // '')
- };
- }
-
- push(@modified, \%hash);
- }
- else {
- $attachment_obj = Bugzilla::Attachment->create({
- bug => $bug,
- creation_ts => $timestamp,
- data => $attachment->{data},
- description => $attachment->{summary},
- filename => $attachment->{file_name},
- mimetype => $attachment->{content_type},
- ispatch => $attachment->{is_patch},
- isprivate => $attachment->{is_private},
- });
-
- if ($flags) {
- my ($old_flags, $new_flags) = extract_flags($flags, $bug, $attachment_obj);
- $attachment_obj->set_flags($old_flags, $new_flags);
- }
-
- push(@created, $attachment_obj);
-
- $attachment_obj->update($timestamp);
- $bug->add_comment($comment,
- { isprivate => $attachment_obj->isprivate,
- type => CMT_ATTACHMENT_CREATED,
- extra_data => $attachment_obj->id });
-
- }
- }
-
- $bug->update($timestamp);
-
- $dbh->bz_commit_transaction();
- $bug->send_changes();
-
- my %attachments_created = map { $_->id => $self->_attachment_to_hash($_, $params) } @created;
- my %attachments_modified = map { (ref $_->{id} ? $_->{id}->value : $_->{id}) => $_ } @modified;
-
- return { attachments_created => \%attachments_created, attachments_modified => \%attachments_modified };
-}
-
-sub rest_resources {
- return [
- qr{^/mozreview/(\d+)/attachments$}, {
- POST => {
- method => 'attachments',
- params => sub {
- return { bug_id => $1 };
- },
- },
- },
- ];
-}
-
-1;
diff --git a/extensions/MozReview/template/en/default/admin/params/mozreview.html.tmpl b/extensions/MozReview/template/en/default/admin/params/mozreview.html.tmpl
deleted file mode 100644
index 4a35555a4..000000000
--- a/extensions/MozReview/template/en/default/admin/params/mozreview.html.tmpl
+++ /dev/null
@@ -1,20 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[%
- title = "MozReview"
- desc = "Configure MozReview"
-%]
-
-[%
- param_descs = {
- mozreview_base_url => 'MozReview Base URL',
- mozreview_auth_callback_url => 'MozReview Auth Delegation URL',
- mozreview_app_id => 'app_id for API Keys delegated to MozReview',
- }
-%]
diff --git a/extensions/MozReview/template/en/default/hook/attachment/create-before_form.html.tmpl b/extensions/MozReview/template/en/default/hook/attachment/create-before_form.html.tmpl
deleted file mode 100644
index bfa842c89..000000000
--- a/extensions/MozReview/template/en/default/hook/attachment/create-before_form.html.tmpl
+++ /dev/null
@@ -1,17 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[% RETURN UNLESS mozreview_enabled %]
-
-<div class="mozreview-ad">
- Are you attaching a patch? Consider trying out
- <a href="https://reviewboard.mozilla.org/">MozReview</a>, Mozilla's
- new repository-based code-review tool.
- <a href="https://mozilla-version-control-tools.readthedocs.io/en/latest/mozreview.html">Read
- the docs</a> to get started.
-</div>
diff --git a/extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl b/extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl
deleted file mode 100644
index 044c36ae9..000000000
--- a/extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl
+++ /dev/null
@@ -1,16 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[%
- RETURN UNLESS attachment.mimetype == "text/x-review-board-request" && attachment.external_redirect;
- custom_attachment_viewer = 1;
- url = attachment.data;
-%]
-<h3>
- <a href="[% url FILTER html %]" title="[% url FILTER html %]">Show review on MozReview</a><br>
-</h3>
diff --git a/extensions/MozReview/template/en/default/hook/bug/edit-after_bug_data.html.tmpl b/extensions/MozReview/template/en/default/hook/bug/edit-after_bug_data.html.tmpl
deleted file mode 100644
index b0e4ce600..000000000
--- a/extensions/MozReview/template/en/default/hook/bug/edit-after_bug_data.html.tmpl
+++ /dev/null
@@ -1,35 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[% RETURN UNLESS mozreview %]
-
-<table class="mozreview-table">
- <thead>
- <tr>
- <th>MozReview Requests</th>
- </tr>
- </thead>
-
- <tbody>
- <tr>
- <td>
- [% INCLUDE moz_review/table.html.tmpl %]
- </td>
- </tr>
- </tbody>
-
- <tfoot>
- <tr class="mozreview-hide-discarded-row bz_default_hidden">
- <td class="mozreview-hide-discarded">
- <a class="mozreview-hide-discarded-link"
- href="#"><span class="mozreview-discarded-action">Show</span>
- discarded requests</a>
- </td>
- </tr>
- </tfoot>
-</table>
diff --git a/extensions/MozReview/template/en/default/hook/bug/show-header-end.html.tmpl b/extensions/MozReview/template/en/default/hook/bug/show-header-end.html.tmpl
deleted file mode 100644
index d70e36b57..000000000
--- a/extensions/MozReview/template/en/default/hook/bug/show-header-end.html.tmpl
+++ /dev/null
@@ -1,13 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[%
- IF mozreview;
- PROCESS moz_review/header.html.tmpl;
- END;
-%]
diff --git a/extensions/MozReview/template/en/default/hook/bug_modal/edit-module.html.tmpl b/extensions/MozReview/template/en/default/hook/bug_modal/edit-module.html.tmpl
deleted file mode 100644
index 9785fa0bd..000000000
--- a/extensions/MozReview/template/en/default/hook/bug_modal/edit-module.html.tmpl
+++ /dev/null
@@ -1,21 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[% RETURN UNLESS mozreview %]
-
-[% WRAPPER bug_modal/module.html.tmpl
- title = "MozReview Requests"
- collapsed = 0
-%]
- [% INCLUDE moz_review/table.html.tmpl %]
- <div class="mozreview-hide-discarded-row bz_default_hidden">
- <button type="button" class="minor mozreview-hide-discarded-link">
- <span class="mozreview-discarded-action">Show</span> discarded requests
- </button>
- </div>
-[% END %]
diff --git a/extensions/MozReview/template/en/default/hook/bug_modal/header-end.html.tmpl b/extensions/MozReview/template/en/default/hook/bug_modal/header-end.html.tmpl
deleted file mode 100644
index d70e36b57..000000000
--- a/extensions/MozReview/template/en/default/hook/bug_modal/header-end.html.tmpl
+++ /dev/null
@@ -1,13 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[%
- IF mozreview;
- PROCESS moz_review/header.html.tmpl;
- END;
-%]
diff --git a/extensions/MozReview/template/en/default/hook/global/header-start.html.tmpl b/extensions/MozReview/template/en/default/hook/global/header-start.html.tmpl
deleted file mode 100644
index 6ad026de6..000000000
--- a/extensions/MozReview/template/en/default/hook/global/header-start.html.tmpl
+++ /dev/null
@@ -1,11 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[% IF template.name == 'attachment/create.html.tmpl' %]
- [% style_urls.push('extensions/MozReview/web/style/attachment.css') %]
-[% END %]
diff --git a/extensions/MozReview/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/MozReview/template/en/default/hook/global/user-error-errors.html.tmpl
deleted file mode 100644
index 151e63b21..000000000
--- a/extensions/MozReview/template/en/default/hook/global/user-error-errors.html.tmpl
+++ /dev/null
@@ -1,15 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[% IF error == "forbidden_method" %]
- The requested method '[% method FILTER html %]' is not allowed to be called using the current API Key.
-[% ELSIF error == "mozreview_attachment_bug_mismatch" %]
- You tried to update attachment [% attachment.id FILTER html %]
- as part of adding or updating attachments on [% bug.id FILTER html %].
- That attachment actually belongs to [% terms.bug %] [% attachment.bug_id FILTER html %].
-[% END %]
diff --git a/extensions/MozReview/template/en/default/moz_review/header.html.tmpl b/extensions/MozReview/template/en/default/moz_review/header.html.tmpl
deleted file mode 100644
index 99fb81ba4..000000000
--- a/extensions/MozReview/template/en/default/moz_review/header.html.tmpl
+++ /dev/null
@@ -1,10 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-[% style_urls.push('extensions/MozReview/web/style/mozreview.css') %]
-[% javascript_urls.push('extensions/MozReview/web/js/mozreview.js') %]
diff --git a/extensions/MozReview/template/en/default/moz_review/table.html.tmpl b/extensions/MozReview/template/en/default/moz_review/table.html.tmpl
deleted file mode 100644
index 84b7add47..000000000
--- a/extensions/MozReview/template/en/default/moz_review/table.html.tmpl
+++ /dev/null
@@ -1,28 +0,0 @@
-[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
- #
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
- #%]
-
-<table class="mozreview-requests" data-mozreview-url="[% Bugzilla.params.mozreview_base_url FILTER html %]">
- <thead>
- <tr>
- <th>Submitter</th>
- <th>Diff</th>
- <th>Changes</th>
- <th>Open Issues</th>
- <th>Last Updated</th>
- </tr>
- </thead>
- <tbody class="mozreview-request">
- <tr class="mozreview-loading-row">
- <td colspan="4">Loading...</td>
- </tr>
- <tr class="mozreview-loading-error-row bz_default_hidden">
- <td colspan="4">Error loading review requests:
- <span class="mozreview-load-error-string"></span></td>
- </tr>
- </tbody>
-</table>
diff --git a/extensions/MozReview/web/js/mozreview.js b/extensions/MozReview/web/js/mozreview.js
deleted file mode 100644
index 6fe51f53b..000000000
--- a/extensions/MozReview/web/js/mozreview.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0.
- */
-
-var MozReview = {};
-
-MozReview.getReviewRequest = function() {
- var hostUrl = $('.mozreview-requests').data('mozreviewUrl');
- var tr = $('<tr/>');
- var td = $('<td/>');
- var link = $('<a/>');
-
- var rrSummaryApiUrl = hostUrl +
- 'api/extensions/mozreview.extension.MozReviewExtension/summary/?bug=' +
- BUGZILLA.bug_id;
- var rrUiBaseUrl = hostUrl + 'r/';
-
- function rrUrl(rrId) {
- return rrUiBaseUrl + rrId + '/';
- }
-
- function rrDiffUrl(rrId) {
- return rrUrl(rrId) + 'diff/#index_header';
- }
-
- function humanizedInt(i) {
- if (i > 1000) {
- return (i / 1000).toFixed(1) + 'k';
- } else {
- return '' + i;
- }
- }
-
- function rrCommitRow(rr, firstCommit) {
- var trCommit = tr.clone();
- var tdSubmitter = td.clone();
- var tdSummary = td.clone();
- var diffLink = link.clone();
- var diffStat = '';
-
- if (firstCommit) {
- tdSubmitter.text(rr.submitter);
- }
-
- tdSummary.addClass('mozreview-summary');
- diffLink.attr('href', rrDiffUrl(rr.id));
- diffLink.text(rr.summary);
- tdSummary.append(diffLink);
-
- if (rr.diff.insert > 0) {
- diffStat = '+' + humanizedInt(rr.diff.insert);
- }
-
- if (rr.diff.delete > 0) {
- if (diffStat.length > 0) {
- diffStat += ' / ';
- }
- diffStat += '-' + humanizedInt(rr.diff.delete);
- }
-
- trCommit.append(
- tdSubmitter,
- tdSummary,
- td.clone().text(diffStat)
- .addClass('mozreview-diffstat'),
- td.clone().text(rr.issue_open_count)
- .addClass('mozreview-open-issues'),
- td.clone().text(timeAgo(new Date(rr.last_updated)))
- );
-
- if (rr.status == "discarded") {
- $('.mozreview-hide-discarded-row').removeClass('bz_default_hidden');
- trCommit.addClass('bz_default_hidden mozreview-discarded-request');
- }
-
- return trCommit;
- }
-
- $('.mozreview-hide-discarded-link').click(function(event) {
- event.preventDefault();
- if ($('.bz_default_hidden.mozreview-discarded-request').length) {
- $('.mozreview-discarded-request').removeClass('bz_default_hidden');
- $('.mozreview-discarded-action').text('Hide');
- } else {
- $('.mozreview-discarded-request').addClass('bz_default_hidden');
- $('.mozreview-discarded-action').text('Show');
- }
- });
-
- var tbody = $('tbody.mozreview-request');
-
- function displayLoadError(errStr) {
- var errRow = tbody.find('.mozreview-loading-error-row');
- errRow.find('.mozreview-load-error-string').text(errStr);
- errRow.removeClass('bz_default_hidden');
- }
-
- $.getJSON(rrSummaryApiUrl, function(data) {
- var family, parent, i, j;
-
- if (data.review_request_summaries.length === 0) {
- displayLoadError('none returned from server');
- } else {
- for (i = 0; i < data.review_request_summaries.length; i++) {
- family = data.review_request_summaries[i];
- for (j = 0; j < family.children.length; j++) {
- tbody.append(rrCommitRow(family.children[j], j == 0));
- }
- }
- }
-
- tbody.find('.mozreview-loading-row').addClass('bz_default_hidden');
- }).fail(function(jqXHR, textStatus, errorThrown) {
- var errStr;
- if (jqXHR.responseJSON && jqXHR.responseJSON.err &&
- jqXHR.responseJSON.err.msg) {
- errStr = jqXHR.responseJSON.err.msg;
- } else if (errorThrown) {
- errStr = errorThrown;
- } else {
- errStr = 'unknown';
- }
- displayLoadError(errStr);
- tbody.find('.mozreview-loading-row').addClass('bz_default_hidden');
- });
-};
-
-$().ready(function() {
- MozReview.getReviewRequest();
-});
diff --git a/extensions/MozReview/web/style/attachment.css b/extensions/MozReview/web/style/attachment.css
deleted file mode 100644
index 474bf466e..000000000
--- a/extensions/MozReview/web/style/attachment.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0. */
-
-.mozreview-ad {
- background-color: #fff9db;
- color: #666458;
- padding: 5px;
- margin-bottom: 10px;
-}
diff --git a/extensions/MozReview/web/style/mozreview.css b/extensions/MozReview/web/style/mozreview.css
deleted file mode 100644
index a2263fc11..000000000
--- a/extensions/MozReview/web/style/mozreview.css
+++ /dev/null
@@ -1,79 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0. */
-
-.mozreview-table {
- background: #fff;
- border: none;
- border-collapse: collapse;
- border-bottom: 1px solid rgba(0, 0, 0, 0.2);
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
-}
-
-.mozreview-table th {
- text-align: left;
- padding: 4px;
-}
-
-.mozreview-table td {
- vertical-align: middle !important;
- padding: 4px !important;
-}
-
-.mozreview-table thead, .mozreview-table tfoot {
- background-color: #eee;
- color: #404040;
-}
-
-.mozreview-requests {
- background: #fff;
- border: none;
- border-collapse: collapse;
-}
-
-.mozreview-requests th {
- padding: 2px;
-}
-
-.mozreview-requests td {
- padding: 2px;
-}
-
-.mozreview-requests .mozreview-summary {
- text-align: left;
-}
-
-.mozreview-requests .mozreview-open-issues {
- text-align: center;
-}
-
-.mozreview-requests .mozreview-diffstat {
- text-align: center;
- white-space: nowrap;
-}
-
-/* bug-modal specific */
-
-#module-mozreview-requests .module-content {
- padding: 0;
-}
-
-.bug_modal .mozreview-table {
- width: 100%;
-}
-
-.bug_modal .mozreview-request td {
- padding-left: 8px;
-}
-
-.bug_modal .mozreview-requests th {
- text-align: left;
- padding-left: 8px;
-}
-
-.bug_modal .mozreview-hide-discarded-row {
- padding: 4px;
-}
diff --git a/extensions/Push/lib/Connector/ReviewBoard.pm b/extensions/Push/lib/Connector/ReviewBoard.pm
deleted file mode 100644
index 1c657a728..000000000
--- a/extensions/Push/lib/Connector/ReviewBoard.pm
+++ /dev/null
@@ -1,178 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-package Bugzilla::Extension::Push::Connector::ReviewBoard;
-
-use 5.10.1;
-use strict;
-use warnings;
-
-use base 'Bugzilla::Extension::Push::Connector::Base';
-
-use Bugzilla::Bug;
-use Bugzilla::BugMail;
-use Bugzilla::Component;
-use Bugzilla::Constants;
-use Bugzilla::Extension::Push::Constants;
-use Bugzilla::Extension::Push::Util;
-use Bugzilla::Group;
-use Bugzilla::Product;
-use Bugzilla::User;
-use Bugzilla::Util qw( trim );
-
-use constant RB_CONTENT_TYPE => 'text/x-review-board-request';
-use constant AUTOMATION_USER => 'automation@bmo.tld';
-
-sub options {
- return (
- {
- name => 'product',
- label => 'Product to create bugs in',
- type => 'string',
- default => 'Developer Services',
- required => 1,
- validate => sub {
- Bugzilla::Product->new({ name => $_[0] })
- || die "Invalid Product ($_[0])\n";
- },
- },
- {
- name => 'component',
- label => 'Component to create bugs in',
- type => 'string',
- default => 'MozReview',
- required => 1,
- validate => sub {
- my ($component, $config) = @_;
- my $product = Bugzilla::Product->new({ name => $config->{product} })
- || die "Invalid Product (" . $config->{product} . ")\n";
- Bugzilla::Component->new({ product => $product, name => $component })
- || die "Invalid Component ($component)\n";
- },
- },
- {
- name => 'version',
- label => "The bug's version",
- type => 'string',
- default => 'Production',
- required => 1,
- validate => sub {
- my ($version, $config) = @_;
- my $product = Bugzilla::Product->new({ name => $config->{product} })
- || die "Invalid Product (" . $config->{product} . ")\n";
- Bugzilla::Version->new({ product => $product, name => $version })
- || die "Invalid Version ($version)\n";
- },
- },
- {
- name => 'group',
- label => 'Security group',
- type => 'string',
- default => 'mozilla-employee-confidential',
- required => 1,
- validate => sub {
- Bugzilla::Group->new({ name => $_[0] })
- || die "Invalid Group ($_[0])\n";
- },
- },
- {
- name => 'cc',
- label => 'Comma separated list of users to CC',
- type => 'string',
- default => '',
- required => 1,
- validate => sub {
- foreach my $login (map { trim($_) } split(',', $_[0])) {
- Bugzilla::User->new({ name => $login })
- || die "Invalid User ($login)\n";
- }
- },
- },
- );
-}
-
-sub should_send {
- my ($self, $message) = @_;
-
- if ($message->routing_key =~ /^(?:attachment|bug)\.modify:.*\bis_private\b/) {
- my $payload = $message->payload_decoded();
- my $target = $payload->{event}->{target};
-
- if ($target ne 'bug' && exists $payload->{$target}->{bug}) {
- return 0 if $payload->{$target}->{bug}->{is_private};
- return 0 if $payload->{$target}->{content_type} ne RB_CONTENT_TYPE;
- }
-
- return $payload->{$target}->{is_private} ? 1 : 0;
- }
- else {
- # We're not interested in the message.
- return 0;
- }
-}
-
-sub send {
- my ($self, $message) = @_;
- my $logger = Bugzilla->push_ext->logger;
- my $config = $self->config;
-
- eval {
- my $payload = $message->payload_decoded();
- my $target = $payload->{event}->{target};
-
- # load attachments
- my $bug_id = $target eq 'bug' ? $payload->{bug}->{id} : $payload->{attachment}->{bug}->{id};
- my $attach_id = $target eq 'attachment' ? $payload->{attachment}->{id} : undef;
- Bugzilla->set_user(Bugzilla::User->super_user);
- my $bug = Bugzilla::Bug->new({ id => $bug_id, cache => 1 });
- Bugzilla->logout;
-
- # create a bug if there are any mozreview attachments
- my @reviews = grep { $_->contenttype eq RB_CONTENT_TYPE } @{ $bug->attachments };
- if (@reviews) {
-
- # build comment
- my $comment = $target eq 'bug'
- ? "Bug $bug_id has MozReview reviews and is no longer public."
- : "MozReview attachment $attach_id on Bug $bug_id is no longer public.";
- $comment .= "\n\n";
- foreach my $attachment (@reviews) {
- $comment .= $attachment->data . "\n";
- }
-
- # create bug
- my $user = Bugzilla::User->new({ name => AUTOMATION_USER, cache => 1 });
- die "Invalid User: " . AUTOMATION_USER . "\n" unless $user;
- Bugzilla->set_user($user);
- my $new_bug = Bugzilla::Bug->create({
- short_desc => "[SECURITY] Bug $bug_id is no longer public",
- product => $config->{product},
- component => $config->{component},
- bug_severity => 'normal',
- groups => [ map { trim($_) } split(',', $config->{group}) ],
- op_sys => 'Unspecified',
- rep_platform => 'Unspecified',
- version => $config->{version},
- cc => [ map { trim($_) } split(',', $config->{cc}) ],
- comment => $comment,
- });
- Bugzilla::BugMail::Send($new_bug->id, { changer => Bugzilla->user });
- Bugzilla->logout;
-
- $logger->info("Created bug " . $new_bug->id);
- }
- };
- my $error = $@;
- Bugzilla->logout;
- if ($error) {
- return (PUSH_RESULT_TRANSIENT, clean_error($error));
- }
-
- return PUSH_RESULT_OK;
-}
-
-1;
diff --git a/extensions/Push/t/ReviewBoard.t b/extensions/Push/t/ReviewBoard.t
deleted file mode 100644
index c752e34ef..000000000
--- a/extensions/Push/t/ReviewBoard.t
+++ /dev/null
@@ -1,225 +0,0 @@
-#!/usr/bin/perl -T
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-use strict;
-use warnings;
-use lib qw( . lib local/lib/perl5 );
-
-use Test::More;
-use Bugzilla;
-use Bugzilla::Extension;
-use Bugzilla::Attachment;
-use Scalar::Util 'blessed';
-
-BEGIN {
- eval {
- require Test::LWP::UserAgent;
- require Test::MockObject;
- };
- if ($@) {
- plan skip_all =>
- 'Tests require Test::LWP::UserAgent and Test::MockObject';
- exit;
- }
-}
-
-BEGIN {
- Bugzilla->extensions; # load all of them
- use_ok 'Bugzilla::Extension::Push::Connector::ReviewBoard::Client';
- use_ok 'Bugzilla::Extension::Push::Constants';
-}
-
-my ($push) = grep { blessed($_) eq 'Bugzilla::Extension::Push' } @{Bugzilla->extensions };
-my $connectors = $push->_get_instance->connectors;
-my $con = $connectors->by_name('ReviewBoard');
-
-my $ua_204 = Test::LWP::UserAgent->new;
-$ua_204->map_response(
- qr{https://reviewboard-dev\.allizom\.org/api/review-requests/\d+},
- HTTP::Response->new('204'));
-
-my $ua_404 = Test::LWP::UserAgent->new;
-$ua_404->map_response(
- qr{https://reviewboard-dev\.allizom\.org/api/review-requests/\d+},
- HTTP::Response->new('404', undef, undef, q[{ "err": { "code": 100, "msg": "Object does not exist" }, "stat": "fail" }]));
-
-# forbidden
-my $ua_403 = Test::LWP::UserAgent->new;
-$ua_403->map_response(
- qr{https://reviewboard-dev\.allizom\.org/api/review-requests/\d+},
- HTTP::Response->new('403', undef, undef, q[ {"err":{"code":101,"msg":"You don't have permission for this"},"stat":"fail"}]));
-
-# not logged in
-my $ua_401 = Test::LWP::UserAgent->new;
-$ua_401->map_response(
- qr{https://reviewboard-dev\.allizom\.org/api/review-requests/\d+},
- HTTP::Response->new('401', undef, undef, q[ { "err": { "code": 103, "msg": "You are not logged in" }, "stat": "fail" } ]));
-
-# not logged in
-my $ua_500 = Test::LWP::UserAgent->new;
-$ua_500->map_response(
- qr{https://reviewboard-dev\.allizom\.org/api/review-requests/\d+},
- HTTP::Response->new('500'));
-
-$con->client->{useragent} = $ua_204;
-$con->config->{base_uri} = 'https://reviewboard-dev.allizom.org';
-$con->client->{base_uri} = 'https://reviewboard-dev.allizom.org';
-
-{
- my $msg = message(
- event => {
- routing_key => 'attachment.modify:is_private',
- target => 'attachment',
- },
- attachment => {
- is_private => 1,
- content_type => 'text/plain',
- bug => { id => 1, is_private => 0 },
- },
- );
-
- ok(not($con->should_send($msg)), "text/plain message should not be sent");
-}
-
-my $data = slurp("extensions/Push/t/rblink.txt");
-Bugzilla::User::DEFAULT_USER->{userid} = 42;
-Bugzilla->set_user(Bugzilla::User->super_user);
-diag " " . Bugzilla::User->super_user->id;
-
-my $dbh = Bugzilla->dbh;
-$dbh->bz_start_transaction;
-my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-my $bug = Bugzilla::Bug->new({id => 9000});
-my $attachment = Bugzilla::Attachment->create({
- bug => $bug,
- creation_ts => $timestamp,
- data => $data,
- attach_size => length($data),
- description => "rblink.txt",
- filename => "rblink.txt",
- isprivate => 1,
- ispatch => 0,
- mimetype => 'text/x-review-board-request'
-});
-diag "".$attachment->id;
-$dbh->bz_commit_transaction;
-
-{
- my $msg = message(
- event => {
- routing_key => 'attachment.modify:cc,is_private',
- target => 'attachment',
- },
- attachment => {
- id => $attachment->id,
- is_private => 1,
- content_type => 'text/x-review-board-request',
- bug => { id => $bug->id, is_private => 0 },
- },
- );
- ok($con->should_send($msg), "rb attachment should be sent");
-
- {
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_OK, "good push result");
- diag $err if $err;
- }
-
- {
- local $con->client->{useragent} = $ua_404;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_OK, "good push result for 404");
- diag $err if $err;
- }
-
-
- {
- local $con->client->{useragent} = $ua_403;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_TRANSIENT, "transient error on 403");
- diag $err if $err;
- }
-
-
- {
- local $con->client->{useragent} = $ua_401;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_TRANSIENT, "transient error on 401");
- diag $err if $err;
- }
-
- {
- local $con->client->{useragent} = $ua_500;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_TRANSIENT, "transient error on 500");
- diag $err if $err;
- }
-}
-
-{
- my $msg = message(
- event => {
- routing_key => 'bug.modify:is_private',
- target => 'bug',
- },
- bug => {
- is_private => 1,
- id => $bug->id,
- },
- );
-
- ok($con->should_send($msg), "rb attachment should be sent");
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_OK, "good push result");
-
- {
- local $con->client->{useragent} = $ua_404;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_OK, "good push result for 404");
- }
-
- {
- local $con->client->{useragent} = $ua_403;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_TRANSIENT, "transient error on 404");
- diag $err if $err;
- }
-
-
- {
- local $con->client->{useragent} = $ua_401;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_TRANSIENT, "transient error on 401");
- diag $err if $err;
- }
-
- {
- local $con->client->{useragent} = $ua_401;
- my ($rv, $err) = $con->send($msg);
- is($rv, PUSH_RESULT_TRANSIENT, "transient error on 401");
- diag $err if $err;
- }
-}
-
-sub message {
- my $msg_data = { @_ };
-
- return Test::MockObject->new
- ->set_always( routing_key => $msg_data->{event}{routing_key} )
- ->set_always( payload_decoded => $msg_data );
-}
-
-sub slurp {
- my $file = shift;
- local $/ = undef;
- open my $fh, '<', $file or die "unable to open $file";
- my $s = readline $fh;
- close $fh;
- return $s;
-}
-
-done_testing;