aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm17
1 files changed, 14 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 5d24bc980..c332830b9 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -636,7 +636,7 @@ sub setup_categories_and_bodies : Private {
= $c #
->model('DB::Contact') #
->active
- ->search( { body_id => [ keys %bodies ] }, { prefetch => 'body' } );
+ ->search( { 'me.body_id' => [ keys %bodies ] }, { prefetch => 'body' } );
my @contacts = $c->cobrand->categories_restriction($contacts)->all;
# variables to populate
@@ -955,7 +955,9 @@ sub process_report : Private {
my $body = $c->model('DB::Body')->search({ name => $single_body_only })->first;
$body ? $body->id : '-1';
} else {
- my $bodies = $c->forward('contacts_to_bodies', [ $report->category ]);
+ my $contact_options = {};
+ $contact_options->{do_not_send} = [ $c->get_param_list('do_not_send', 1) ];
+ my $bodies = $c->forward('contacts_to_bodies', [ $report->category, $contact_options ]);
join(',', map { $_->id } @$bodies) || '-1';
}
};
@@ -1014,10 +1016,19 @@ sub process_report : Private {
}
sub contacts_to_bodies : Private {
- my ($self, $c, $category) = @_;
+ my ($self, $c, $category, $options) = @_;
my @contacts = grep { $_->category eq $category } @{$c->stash->{contacts}};
+ # check that the front end has not indicated that we should not send to a
+ # body. This is usually because the asset code thinks it's not near enough
+ # to a road.
+ if ($options->{do_not_send}) {
+ my %do_not_send_check = map { $_ => 1 } @{$options->{do_not_send}};
+ my @contacts_filtered = grep { !$do_not_send_check{$_->body->name} } @contacts;
+ @contacts = @contacts_filtered if scalar @contacts_filtered;
+ }
+
if ($c->stash->{unresponsive}{$category} || $c->stash->{unresponsive}{ALL} || !@contacts) {
[];
} else {