diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-12-11 11:04:43 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-12-11 11:32:21 +0000 |
commit | d31201ac8cbc724ecb04d1a4744186876d2d5f5b (patch) | |
tree | a7e8b7c55f61fdc4ac7f248fa71b05b6f3e588fa | |
parent | 6ea3d7f26b8b54ed52e0a90f1e4d7976081c4e3f (diff) |
[UK] Fix links in submit email.
For an email to somewhere for which the report has a body handler, we
want to use that cobrand's domain for the link - we already are using
their cobrand for the email template, after all.
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 9 | ||||
-rw-r--r-- | t/cobrand/tfl.t | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index 9725f1781..aed4e2fc6 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -46,6 +46,9 @@ sub send(;$) { my $cobrand = $row->get_cobrand_logged; FixMyStreet::DB->schema->cobrand($cobrand); + # Also get a cobrand that handles where a report is going + my $cobrand_handler = $cobrand->call_hook(get_body_handler_for_problem => $row) || $cobrand; + if ($debug_mode) { $debug_unsent_count++; print "\n"; @@ -62,7 +65,7 @@ sub send(;$) { } $cobrand->set_lang_and_domain($row->lang, 1); - FixMyStreet::Map::set_map_class($cobrand->map_type); + FixMyStreet::Map::set_map_class($cobrand_handler->map_type); if ( $row->is_from_abuser) { $row->update( { state => 'hidden' } ); debug_print("hiding because its sender is flagged as an abuser", $row->id) if $debug_mode; @@ -74,7 +77,7 @@ sub send(;$) { } # Template variables for the email - my $email_base_url = $cobrand->base_url_for_report($row); + my $email_base_url = $cobrand_handler->base_url_for_report($row); my %h = map { $_ => $row->$_ } qw/id title detail name category latitude longitude used_map/; $h{report} = $row; $h{cobrand} = $cobrand; @@ -84,7 +87,7 @@ sub send(;$) { $h{query} = $row->postcode; $h{url} = $email_base_url . $row->url; - $h{admin_url} = $row->admin_url($cobrand); + $h{admin_url} = $row->admin_url($cobrand_handler); if ($row->photo) { $h{has_photo} = _("This web page also contains a photo of the problem, provided by the user.") . "\n\n"; $h{image_url} = $email_base_url . $row->photos->[0]->{url_full}; diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t index 287a8c98e..86b172f5a 100644 --- a/t/cobrand/tfl.t +++ b/t/cobrand/tfl.t @@ -422,6 +422,7 @@ for my $test ( FixMyStreet::Script::Reports::send(); my @email = $mech->get_email; is $email[0]->header('To'), $to, 'Sent to correct address'; + like $mech->get_text_body_from_email($email[0]), qr/https:\/\/street.tfl/, 'Correct link'; $mech->clear_emails_ok; FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report for borough team'})->delete; }; |