Skip to content

Commit

Permalink
"Email sent" page is false
Browse files Browse the repository at this point in the history
This page was shown even if the email didn't send: the redirect was
unconditional, and the "sent" parameter was always included, which made the
`exists` check for that parameter completely useless.

Now it reloads the form (preserving what was entered).
  • Loading branch information
mwiencek committed Nov 12, 2024
1 parent 7a95deb commit e1102ea
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/MusicBrainz/Server/Controller/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -373,25 +373,26 @@ sub contact : Chained('load') RequireAuth HiddenOnMirrors SecureForm
my $form = $c->form( form => 'User::Contact' );

if ($c->form_posted_and_valid($form)) {

my $result;
my $sent;
try {
$result = $c->model('Email')->send_message_to_editor(
$c->model('Email')->send_message_to_editor(
from => $c->user,
to => $editor,
subject => $form->value->{subject},
message => $form->value->{body},
reveal_address => $form->value->{reveal_address},
send_to_self => $form->value->{send_to_self},
);
$sent = 1;
}
catch {
log_debug { "Couldn't send email: $_" } $_;
$c->flash->{message} = l('Your message could not be sent');
};

$c->res->redirect($c->uri_for_action('/user/contact', [ $editor->name ], { sent => $result }));
$c->detach;
if ($sent) {
$c->res->redirect($c->uri_for_action('/user/contact', [ $editor->name ], { sent => 1 }));
$c->detach;
}
}

$c->stash(
Expand Down

0 comments on commit e1102ea

Please sign in to comment.