Skip to content

Commit

Permalink
[Oxfordshire] Send additional email on category
Browse files Browse the repository at this point in the history
Oxfordshire would like the category 'Trees obscuring street lights'
to send an additional email as well as being sent over open311.

https://mysocietysupport.freshdesk.com/a/tickets/4741
  • Loading branch information
MorayMySoc authored and neprune committed Jan 16, 2025
1 parent fbbb05a commit 1e500b4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
15 changes: 15 additions & 0 deletions perllib/FixMyStreet/Cobrand/Oxfordshire.pm
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ sub report_inspect_update_extra {
}
}

sub open311_post_send {
my ($self, $row, $h, $sender) = @_;

if ($row->category eq 'Trees obstructing traffic light' && !$row->get_extra_metadata('extra_email_sent')) {
my $emails = $self->feature('open311_email');
if (my $dest = $emails->{$row->category}) {
my $sender = FixMyStreet::SendReport::Email->new( to => [ $dest ]);
$sender->send($row, $h);
if ($sender->success) {
$row->update_extra_metadata(extra_email_sent => 1);
}
}
}
}

sub on_map_default_status { return 'open'; }

sub around_nearby_filter {
Expand Down
35 changes: 35 additions & 0 deletions t/cobrand/oxfordshire.t
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,39 @@ FixMyStreet::override_config {
};
};

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'oxfordshire',
STAGING_FLAGS => { send_reports => 1 },
COBRAND_FEATURES => {
sub_ward_reporting => { oxfordshire => ['DIW', 'CPC'] },
open311_email => { oxfordshire => { 'Trees obstructing traffic light' => '[email protected]' } }
},
MAPIT_URL => 'http://mapit.uk/',


}, sub {
subtest "Trees obstructing traffic light category sends email too" => sub {
$mech->create_contact_ok( body_id => $oxon->id, category => 'Trees obstructing traffic light', email => 'OPEN311', send_method => 'Open311');
my ($report) = $mech->create_problems_for_body( 1, $oxon->id, 'Traffic light hidden', {
cobrand => 'oxfordshire',
category => 'Trees obstructing traffic light',
latitude => 51.754926,
longitude => -1.256179,
});
FixMyStreet::Script::Reports::send();
my @emails = $mech->get_email;
my $confirm_sent;
for my $email (@emails) {
my %headers = $email->header_str_pairs;
$confirm_sent = 1 if $headers{To} eq '[email protected]';
};
is $confirm_sent, 1, "Traffic light email sent to traffic light email address";
my $req = Open311->test_req_used;
my $c = CGI::Simple->new($req->content);
is $c->{description}[0] =~ /Traffic light hidden/, 1, "Traffic light report also sent to open311";
};

};


done_testing();

0 comments on commit 1e500b4

Please sign in to comment.