diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-05-11 09:54:41 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-12-06 11:07:14 +0100 |
commit | 59f4001bc48fc7bef1dcc58175a06737ede02fc8 (patch) | |
tree | e419a51dc87367b6bab64f1d8cd1794c0300bd08 | |
parent | c5dd6287212378d91706d36aa7e483eb69b807f9 (diff) | |
download | bugzilla-59f4001bc48fc7bef1dcc58175a06737ede02fc8.tar.gz bugzilla-59f4001bc48fc7bef1dcc58175a06737ede02fc8.tar.xz |
Adapt flyspray migration to work without username and only email
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | Bugzilla/Migrate/Flyspray.pm | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Bugzilla/Migrate/Flyspray.pm b/Bugzilla/Migrate/Flyspray.pm index 6f499bc4a..406bb8f66 100644 --- a/Bugzilla/Migrate/Flyspray.pm +++ b/Bugzilla/Migrate/Flyspray.pm @@ -108,7 +108,7 @@ END }, { name => 'component_owner', - default => 'bluewind', + default => 'bluewind@xinu.at', desc => <<'END', # The username of the user that is set as the initial owner for components. END @@ -183,29 +183,29 @@ sub _read_users { my @result; while (my $row = $sth->fetchrow_hashref()) { - next unless validate_email_syntax($row->{email_address}); + if (!validate_email_syntax($row->{email_address})) { + $self->debug("Skipping invalid email: " . $row->{email_address}, 3); + next; + } my $item = { - login_name => $row->{user_name} =~ s/\s//gr =~ s/@//gr, + login_name => $row->{email_address}, realname => $row->{real_name}, - email => $row->{email_address}, cryptpassword => "*", }; push @result, $item; - $self->{map_user_id_to_email}->{$row->{user_id}} = $item->{email}; - $self->{map_email_to_name}->{$row->{email_address}} = $item->{login_name}; + $self->{map_user_id_to_email}->{$row->{user_id}} = $item->{login_name}; } - # Remove duplicate users based on email; keep the latesst account + # Remove duplicate users based on email; keep the latest account my %seen; - @result = reverse grep { !$seen{$_->{email}}++ } reverse @result; + @result = reverse grep { !$seen{$_->{login_name}}++ } reverse @result; # fallback user for cases where the real user can not be # created or has been deleted push @result, { - login_name => 'UnknownUser', + login_name => $self->config("unknown_user_email"), realname => 'Unknown User', - email => $self->config("unknown_user_email"), cryptpassword => "*", is_enabled => 0, }; @@ -529,7 +529,7 @@ sub _get_username { my ($self, $userid) = @_; my $email = $self->{map_user_id_to_email}->{$userid // -1} // $self->{map_user_id_to_email}->{-1}; - return $self->{map_email_to_name}->{$email}; + return $email; } |