diff --git a/perllib/FixMyStreet/Cobrand/Bexley.pm b/perllib/FixMyStreet/Cobrand/Bexley.pm index 2032c96ec3f..77af3076660 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley.pm @@ -216,6 +216,8 @@ sub open311_post_send { my $emails = $self->feature('open311_email') || return; my $dangerous = $row->get_extra_field_value('dangerous') || ''; + my $is_out_of_hours = _is_out_of_hours(); + my $p1_email = 0; my $outofhours_email = 0; if ($row->category eq 'Abandoned and untaxed vehicles') { @@ -251,7 +253,9 @@ sub open311_post_send { if ($blocking eq 'Yes' || $hazardous eq 'Yes') { $outofhours_email = 1; } - $p1_email = 1; + if (!$is_out_of_hours || ($blocking eq 'Yes' && $hazardous eq 'Yes')) { + $p1_email = 1; + } } elsif ($row->category eq 'Alleyway') { #FlytippingAlleyway $p1_email = 1 if $dangerous eq 'Yes'; } elsif ($row->category eq 'Obstructions on pavements and roads') { @@ -278,7 +282,7 @@ sub open311_post_send { push @to, email_list($p1_email_to_use, '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(); + 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 }); diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t index aec34961a63..76298498ac1 100644 --- a/t/cobrand/bexley.t +++ b/t/cobrand/bexley.t @@ -149,9 +149,15 @@ FixMyStreet::override_config { extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } }, { category => 'Flytipping', code => 'UniformFLY', email => ['eh'] }, { category => 'Graffiti', code => 'GRAF', email => ['p1'], extra => { 'name' => 'offensive', description => 'Is the graffiti racist or offensive?', 'value' => 'Yes' } }, - { category => 'Carriageway', code => 'CARRIAGEWAY', email => ['p1'] }, - { category => 'Carriageway', code => 'CARRIAGEWAY', email => ['p1', 'outofhours', 'ooh2'], + { category => 'Carriageway', code => 'CARRIAGEWAY', }, + { category => 'Carriageway', code => 'CARRIAGEWAY', email => ['outofhours', 'ooh2'], extra => { 'name' => 'blocking', description => 'Flytipping blocking carriageway?', 'value' => 'Yes' } }, + { category => 'Carriageway', code => 'CARRIAGEWAY', email => ['p1', 'outofhours', 'ooh2'], + extra => [ + { 'name' => 'blocking', description => 'Flytipping blocking carriageway?', 'value' => 'Yes' }, + { 'name' => 'hazardous', value => 'Yes' }, + ], + }, { category => 'Obstructions on pavements and roads', code => 'OBSTR', email => ['p1'], extra => { 'name' => 'reportType', description => 'Type of obstruction?', 'value' => 'Tables and Chairs' } }, { category => 'Obstructions on pavements and roads', code => 'OBSTR', email => ['p1', 'outofhours', 'ooh2'],