aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-03-11 16:48:32 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-03-12 11:56:07 +0000
commit25792b5e3bdebd3d1d13c370c4d6da0db3d38cef (patch)
tree0f3538580b6742de50ec162d67854df90e5d3e28
parentc97eb13c2920103416c19ec526304fd07d44c386 (diff)
[Open311] Proper bodies check for sending updates.
Otherwise running on a site where one body ID is a substring of another, comments can get processed for the wrong body.
-rw-r--r--CHANGELOG.md1
-rwxr-xr-xperllib/Open311/PostServiceRequestUpdates.pm4
-rw-r--r--t/open311/post-service-request-updates.t4
3 files changed, 4 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eeea670eb..7461fbf85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@
- Improve inline checkbox spacing. #2411
- Prevent duplicate contact history creation with Unicode data.
- Show all Open311 extra fields in edit admin.
+ - Proper bodies check for sending updates.
- Development improvements:
- Make front page cache time configurable.
- Better working of /fakemapit/ under https.
diff --git a/perllib/Open311/PostServiceRequestUpdates.pm b/perllib/Open311/PostServiceRequestUpdates.pm
index e2172c028..c8ff2130f 100755
--- a/perllib/Open311/PostServiceRequestUpdates.pm
+++ b/perllib/Open311/PostServiceRequestUpdates.pm
@@ -52,18 +52,16 @@ sub process_body {
my $o = Open311->new( $self->open311_params($body) );
- my $comments = FixMyStreet::DB->resultset('Comment')->search( {
+ my $comments = FixMyStreet::DB->resultset('Comment')->to_body($body)->search( {
'me.whensent' => undef,
'me.external_id' => undef,
'me.state' => 'confirmed',
'me.confirmed' => { '!=' => undef },
'problem.whensent' => { '!=' => undef },
'problem.external_id' => { '!=' => undef },
- 'problem.bodies_str' => { -like => '%' . $body->id . '%' },
'problem.send_method_used' => { -like => '%Open311%' },
},
{
- join => 'problem',
order_by => [ 'confirmed', 'id' ],
}
);
diff --git a/t/open311/post-service-request-updates.t b/t/open311/post-service-request-updates.t
index 5c8211bbf..901181501 100644
--- a/t/open311/post-service-request-updates.t
+++ b/t/open311/post-service-request-updates.t
@@ -15,8 +15,8 @@ my $params = {
endpoint => 'endpoint',
jurisdiction => 'home',
};
-my $bromley = $mech->create_body_ok(2482, 'Bromley', { %$params, send_extended_statuses => 1 });
-my $oxon = $mech->create_body_ok(2237, 'Oxfordshire', $params);
+my $bromley = $mech->create_body_ok(2482, 'Bromley', { %$params, send_extended_statuses => 1, id => 5 });
+my $oxon = $mech->create_body_ok(2237, 'Oxfordshire', { %$params, id => 55 });
my $bucks = $mech->create_body_ok(2217, 'Buckinghamshire', $params);
my $lewisham = $mech->create_body_ok(2492, 'Lewisham', $params);