From ee884993aae404c92c6114b1d044d2e332d25fe1 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 15 Oct 2018 16:16:01 +0200 Subject: Flyspray: Create watch users Signed-off-by: Florian Pritz --- Bugzilla/Migrate/Flyspray.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/Bugzilla/Migrate/Flyspray.pm b/Bugzilla/Migrate/Flyspray.pm index b0fcf29e6..527997361 100644 --- a/Bugzilla/Migrate/Flyspray.pm +++ b/Bugzilla/Migrate/Flyspray.pm @@ -223,6 +223,17 @@ sub _read_users { return \@result; } +sub _add_user { + my $self = shift; + my $email = shift; + my $real_name = shift; + + my $item + = {login_name => $email, realname => $real_name, cryptpassword => "*",}; + push @{$self->{users}}, $item; + $self->{email_to_keep}->{$email} = 1; +} + sub _read_products { my $self = shift; @@ -236,9 +247,10 @@ sub _read_products { name => $row->{project_title}, description => $row->{intro_message} || "N/A", isactive => 1, - components => $self->_get_fs_project_components($row->{project_id}), - version => "unspecified", - groups => [ + components => + $self->_get_fs_project_components($row->{project_id}, $row->{project_title}), + version => "unspecified", + groups => [ { name => "private", description => "Private bug group", @@ -257,8 +269,11 @@ sub _read_products { } sub _get_fs_project_components { - my $self = shift; - my $project_id = shift; + my $self = shift; + my $project_id = shift; + my $project_title = shift; + + my $watch_project_title = ($project_title =~ s/[^a-zA-Z0-9]//gr); my $sth = $self->_select_fs( ["list_category"], @@ -268,24 +283,31 @@ sub _get_fs_project_components { my @result; while (my $row = $sth->fetchrow_hashref()) { + my $watch_component_name = ($row->{category_name} =~ s/[^a-zA-Z0-9]//gr); + my $watch_user = $watch_component_name . '@' . $watch_project_title . '.bugs'; push @result, { name => $row->{category_name}, description => "N/A", initialowner => $self->config("component_owner"), isactive => 1, + watch_user => $watch_user, }; + $self->_add_user($watch_user, undef); $self->{map_component_id_to_name}->{$row->{category_id}} = $row->{category_name}; $self->{project_id_components}->{$project_id}->{$row->{category_name}} = 1; } + my $watch_user = 'uncategorized@' . $watch_project_title . '.bugs'; push @result, { name => "Uncategorized", description => "N/A", initialowner => $self->config("component_owner"), isactive => 1, + watch_user => $watch_user, }; + $self->_add_user($watch_user, undef); $self->{map_component_id_to_name}->{-1} = "Uncategorized"; $self->debug(\@result, 3); -- cgit v1.2.3-24-g4f1b