diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index e885a68742e..d83c58f91fc 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -400,7 +400,7 @@ appropriately. =cut sub open311_get_update_munging { - my ($self, $comment, $state) = @_; + my ($self, $comment, $state, $request) = @_; # An update from Bromley with a special referral state if ($state eq 'referred to veolia streets') { @@ -428,7 +428,7 @@ sub open311_get_update_munging { # Fetch outgoing notes my $echo = $self->feature('echo'); $echo = Integrations::Echo->new(%$echo); - my $event = $echo->GetEvent($problem->external_id); + my $event = $echo->GetEvent($request->{service_request_id}); # From the event, not the report $echo->log($event->{Data}); my $data = Integrations::Echo::force_arrayref($event->{Data}, 'ExtensibleDatum'); my $notes = ""; diff --git a/perllib/Open311/UpdatesBase.pm b/perllib/Open311/UpdatesBase.pm index 0e622e3ca07..35b80adc8ed 100644 --- a/perllib/Open311/UpdatesBase.pm +++ b/perllib/Open311/UpdatesBase.pm @@ -289,7 +289,7 @@ sub _process_update { || ($comment->problem_state && $state ne $old_state); my $cobrand = $body->get_cobrand_handler; - $cobrand->call_hook(open311_get_update_munging => $comment, $state) + $cobrand->call_hook(open311_get_update_munging => $comment, $state, $request) if $cobrand; # As comment->created has been looked at above, its time zone has been shifted diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index 6942597c96b..a86ff4379a5 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -706,6 +706,9 @@ subtest 'redirecting of reports between backends' => sub { ] } }, }); } elsif ($method eq 'GetEvent') { + my ($key, $type, $value) = ${$args[3]->value}->value; + my $external_id = ${$value->value}->value->value; + is $external_id, 'guid'; return SOAP::Result->new(result => { Guid => 'hmm', Id => 'id', @@ -768,7 +771,7 @@ subtest 'redirecting of reports between backends' => sub { whensent => DateTime->now, }); - my $in = $mech->echo_notify_xml('guid', 2104, 15004, 1252); + my $in = $mech->echo_notify_xml('guid', 2104, 15004, 1252, 'FMS-' . $report->id); my $detail = $report->detail; subtest 'A report sent to Confirm, then redirected to Echo' => sub { @@ -810,7 +813,7 @@ subtest 'redirecting of reports between backends' => sub { is $c->param('description'), "$detail | Handover notes - This is a handover note"; }; subtest '...then redirected back to Confirm' => sub { - $report->update({ external_id => 'guid', whensent => DateTime->now, send_method_used => 'Open311' }); + $report->update({ external_id => 'parent-guid', whensent => DateTime->now, send_method_used => 'Open311' }); $mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in); is $report->comments->count, 2, 'A new update'; $report->discard_changes; @@ -833,12 +836,12 @@ subtest 'redirecting of reports between backends' => sub { subtest 'A report sent to Echo, redirected to Confirm' => sub { $report->comments->delete; $report->unset_extra_metadata('original_bromley_external_id'); - $report->update({ external_id => 'guid' }); + $report->update({ external_id => 'original-guid' }); $mech->post('/waste/echo', Content_Type => 'text/xml', Content => $in); is $report->comments->count, 1, 'A new update'; $report->discard_changes; is $report->whensent, undef; - is $report->external_id, 'guid', 'ID not changed'; + is $report->external_id, 'original-guid', 'ID not changed'; is $report->state, 'in progress', 'A state change'; is $report->category, 'Environmental Services'; FixMyStreet::Script::Reports::send();