diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-12-23 15:23:55 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-12-23 15:29:02 +0000 |
commit | 36fc093d2fe61bca3cbf44d2a6e9c8bc795714cd (patch) | |
tree | 27115f0c2dc4ae956aa613519de78ea2c8930218 | |
parent | b398440b4f37df99754ef347da75bf78ea7c37ba (diff) |
[Bexley] Consistent email, always allow lists.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bexley.pm | 31 | ||||
-rw-r--r-- | t/cobrand/bexley.t | 6 |
2 files changed, 17 insertions, 20 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm index 5a382e262..fd90a1c30 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley.pm @@ -155,23 +155,12 @@ sub open311_post_send { } my @to; - if ($p1_email) { - push @to, [ $emails->{p1}, 'Bexley P1 email' ] if $emails->{p1}; - } - if ($lighting{$row->category} && $emails->{lighting}) { - my @lighting = split /,/, $emails->{lighting}; - push @to, [ $_, 'FixMyStreet Bexley Street Lighting' ] for @lighting; - } - if ($flooding{$row->category} && $emails->{flooding}) { - my @flooding = split /,/, $emails->{flooding}; - push @to, [ $_, 'FixMyStreet Bexley Flooding' ] for @flooding; - } - if ($outofhours_email && _is_out_of_hours() && $emails->{outofhours}) { - push @to, [ $emails->{outofhours}, 'Bexley out of hours' ]; - } - if ($contact->email =~ /^Uniform/ && $emails->{eh}) { - my @eh = split ',', $emails->{eh}; - push @to, [ $_, 'FixMyStreet Bexley EH' ] for @eh; + push @to, email_list($emails->{p1}, 'Bexley P1 email') if $p1_email; + push @to, email_list($emails->{lighting}, 'FixMyStreet Bexley Street Lighting') if $lighting{$row->category}; + push @to, email_list($emails->{flooding}, 'FixMyStreet Bexley Flooding') if $flooding{$row->category}; + push @to, email_list($emails->{outofhours}, 'Bexley out of hours') if $outofhours_email && _is_out_of_hours(); + if ($contact->email =~ /^Uniform/) { + push @to, email_list($emails->{eh}, 'FixMyStreet Bexley EH'); $row->push_extra_fields({ name => 'uniform_id', description => 'Uniform ID', value => $row->external_id }); } @@ -186,6 +175,14 @@ sub open311_post_send { $sender->send($row, $h); } +sub email_list { + my ($emails, $name) = @_; + return unless $emails; + my @emails = split /,/, $emails; + my @to = map { [ $_, $name ] } @emails; + return @to; +} + sub dashboard_export_problems_add_columns { my $self = shift; my $c = $self->{c}; diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t index d639f9be9..d9b41f3b1 100644 --- a/t/cobrand/bexley.t +++ b/t/cobrand/bexley.t @@ -51,7 +51,7 @@ FixMyStreet::override_config { COBRAND_FEATURES => { open311_email => { bexley => { p1 => 'p1@bexley', lighting => 'thirdparty@notbexley.example.com,another@notbexley.example.com', - outofhours => 'outofhours@bexley', + outofhours => 'outofhours@bexley,ooh2@bexley', flooding => 'flooding@bexley', eh => 'eh@bexley', } } }, @@ -74,8 +74,8 @@ FixMyStreet::override_config { extra => { 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'Yes' } }, { category => 'Abandoned and untaxed vehicles', code => 'ABAN', extra => { 'name' => 'burnt', description => 'Was it burnt?', 'value' => 'No' } }, - { category => 'Dead animal', email => ['p1', 'outofhours'], code => 'ANIM' }, - { category => 'Something dangerous', email => ['p1', 'outofhours'], code => 'DANG', + { category => 'Dead animal', email => ['p1', 'outofhours', 'ooh2'], code => 'ANIM' }, + { category => 'Something dangerous', email => ['p1', 'outofhours', 'ooh2'], code => 'DANG', extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } }, { category => 'Something dangerous', code => 'DANG', extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } }, |