Skip to content

Commit

Permalink
MBS-13876: Verification emails
Browse files Browse the repository at this point in the history
  • Loading branch information
JadedBlueEyes committed Dec 30, 2024
1 parent 7c01629 commit 30b97d6
Showing 1 changed file with 19 additions and 39 deletions.
58 changes: 19 additions & 39 deletions lib/MusicBrainz/Server/Email.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,43 +88,6 @@ sub _create_email
});
}

sub _create_email_verification_email
{
my ($self, %opts) = @_;

my @headers = (
'To' => $opts{email},
'From' => $EMAIL_NOREPLY_ADDRESS,
'Reply-To' => $EMAIL_SUPPORT_ADDRESS,
'Message-Id' => _message_id('verify-email-%s', generate_gid()),
'Subject' => 'Please verify your email address',
);

my $verification_link = $opts{verification_link};
my $ip = $opts{ip};
my $user_name = $opts{editor}->name;

my $body = <<"EOS";
Hello $user_name,
This is a verification email for your MusicBrainz account. Please click
on the link below to verify your email address:
$verification_link
If clicking the link above doesn't work, please copy and paste the URL in a
new browser window instead.
This email was triggered by a request from the IP address [$ip].
Thanks for using MusicBrainz!
-- The MusicBrainz Team
EOS

return $self->_create_email(\@headers, $body);
}

sub _create_email_in_use_email
{
my ($self, %opts) = @_;
Expand Down Expand Up @@ -446,8 +409,25 @@ sub send_email_verification
{
my ($self, %opts) = @_;

my $email = $self->_create_email_verification_email(%opts);
return $self->_send_email($email);
my $verification_link = $opts{verification_link};
my $ip = $opts{ip};
my $user_name = $opts{editor}->name;

my $body = {
template_id => 'verify-email',
to => $opts{email},
from => $EMAIL_NOREPLY_ADDRESS,
reply_to => $EMAIL_NOREPLY_ADDRESS,
# TODO: send the user's language preference here.
message_id => _message_id('verify-email-%s', generate_gid()),
params => {
to_name => $user_name,
verification_url => ${ $verification_link },
# TODO: Do we include the IP address, like with the previous email?
},
};

$self->_mb_mail_service_send_single($body);
}

sub send_email_in_use
Expand Down

0 comments on commit 30b97d6

Please sign in to comment.