aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin.pm
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-10-18 18:20:07 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-10-26 16:22:11 +0100
commite1636f3c8cb837c3debe28da7532778493ebad54 (patch)
tree08294e6d0f7eaa6ffac876dec909833bc3395ab4 /perllib/FixMyStreet/App/Controller/Admin.pm
parent2e8c2dcdb299e1c34e0c64120ad2b513ec980491 (diff)
Resend report if changing category changes body.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm10
1 files changed, 7 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 07a6e7f3c..748842df5 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -8,10 +8,10 @@ use Path::Class;
use POSIX qw(strftime strcoll);
use Digest::SHA qw(sha1_hex);
use mySociety::EmailUtil qw(is_valid_email);
+use mySociety::ArrayUtils;
use DateTime::Format::Strptime;
use List::Util 'first';
-
use FixMyStreet::SendReport;
=head1 NAME
@@ -852,8 +852,12 @@ sub report_edit_category : Private {
if ((my $category = $c->get_param('category')) ne $problem->category) {
$problem->category($category);
my @contacts = grep { $_->category eq $problem->category } @{$c->stash->{contacts}};
- my $bs = join( ',', map { $_->body_id } @contacts );
- $problem->bodies_str($bs);
+ my @new_body_ids = map { $_->body_id } @contacts;
+ # If the report has changed bodies we need to resend it
+ if (scalar @{mySociety::ArrayUtils::symmetric_diff($problem->bodies_str_ids, \@new_body_ids)}) {
+ $problem->whensent(undef);
+ }
+ $problem->bodies_str(join( ',', @new_body_ids ));
}
}