-
-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MBS-13719: Enable sending contact emails through new service #3390
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting this, I hope we can put it on test/beta soon!
{ | ||
my $email = $self->_create_message_to_editor_email(%opts); | ||
$self->_send_email($email); | ||
my $_url = $mail_service_base_url . "/send_single"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May as well use interpolation here since we're already using the double quotes:
my $_url = $mail_service_base_url . "/send_single"; | |
my $_url = "$mail_service_base_url/send_single"; |
'template_id' => 'editor-message', | ||
'to' => _user_address($to), | ||
'from' => $EMAIL_NOREPLY_ADDRESS, | ||
# 'lang' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change this to a "TODO" comment saying we'll use a not-yet-added mail language preference here?
'to_name' => $to -> name, | ||
'from_name' => $from -> name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small style suggestion for consistency with the rest of our Perl code
'to_name' => $to -> name, | |
'from_name' => $from -> name, | |
'to_name' => $to->name, | |
'from_name' => $from->name, |
Please do not respond to this e-mail. | ||
EOF | ||
my $res = $self->c->lwp->request(POST $_url, %$header_params, Content => encode_json($body)); | ||
if (! $res->is_success) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small style suggestion for consistency with the rest of our Perl code
if (! $res->is_success) { | |
if (!$res->is_success) { |
or
if (! $res->is_success) { | |
unless ($res->is_success) { |
EOF | ||
my $res = $self->c->lwp->request(POST $_url, %$header_params, Content => encode_json($body)); | ||
if (! $res->is_success) { | ||
print "Failed to send!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should die
here (which will show the user an error page) rather than continue with the send-to-self path. We can also provide some extra details about the failed response:
my $status = $res->status;
die "Failed to send mail ($status):\n" . Dumper($res->content);
This requires importing use Data::Dumper;
.
|
||
$self->_send_email($copy); | ||
if ($opts{send_to_self}) { | ||
my $self_body = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine to just reuse the previous $body
:
$body->{to} = _user_address($from);
$body->{params}{is_self_copy} = \1;
|
||
my $res = $self->c->lwp->request(POST $_url, %$header_params, Content => encode_json($self_body)); | ||
if (! $res->is_success) { | ||
print "Failed to send!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment re: die
above.
Problem
This is the start of enabling
mb-mail-service
incrementally, as a broken-down version of #3363.This adds the configuration option
MAIL_SERVICE_BASE_URL
in DBdefs, and replacessend_message_to_editor
(aka/user/<id>/contact
) with the new template.Testing
This has been manually tested.
Documenting
Further action