Skip to content

Commit

Permalink
[Bromley] Look up event GUID on council redirect.
Browse files Browse the repository at this point in the history
Both the parent and client event updates are coming through to us
on the same report, as they have the same client reference, and
the parent event GUID is the one stored on the report, but we
need to look up the child event when we receive an update on
the child.
  • Loading branch information
dracos committed Oct 11, 2024
1 parent f57791c commit efeb221
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions perllib/FixMyStreet/Cobrand/Bromley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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 = "";
Expand Down
2 changes: 1 addition & 1 deletion perllib/Open311/UpdatesBase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions t/cobrand/bromley.t
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit efeb221

Please sign in to comment.