diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/SendReport/Email/Highways.pm | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/SendReport/Email/Highways.pm b/perllib/FixMyStreet/SendReport/Email/Highways.pm index 2a1f7b305..2bcd120d3 100644 --- a/perllib/FixMyStreet/SendReport/Email/Highways.pm +++ b/perllib/FixMyStreet/SendReport/Email/Highways.pm @@ -1,11 +1,25 @@ package FixMyStreet::SendReport::Email::Highways; use Moo; -extends 'FixMyStreet::SendReport::Email::SingleBodyOnly'; +extends 'FixMyStreet::SendReport::Email'; -has contact => ( - is => 'ro', - default => 'Pothole' -); +sub build_recipient_list { + my ( $self, $row, $h ) = @_; + + return unless @{$self->bodies} == 1; + my $body = $self->bodies->[0]; + + my $contact = $self->fetch_category($body, $row) or return; + my $email = $contact->email; + my $area_name = $row->get_extra_field_value('area_name') || ''; + if ($area_name eq 'Area 7') { + my $a7email = FixMyStreet->config('COBRAND_FEATURES') || {}; + $a7email = $a7email->{open311_email}->{highwaysengland}->{area_seven}; + $email = $a7email if $a7email; + } + + @{$self->to} = map { [ $_, $body->name ] } split /,/, $email; + return 1; +} 1; |