From 1f69e28c518f4da9165ae03b749f3411ecec46fd Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 6 Sep 2018 14:08:26 +0100 Subject: Check all contacts for metadata and non-public. Previously it would only check the first matching entry, which could miss out on information if two bodies had the same category and only the second one looked at had metadata, or was marked as non-public. --- perllib/FixMyStreet/App/Controller/Report/New.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Report') diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 8fadbac88..15d144e2a 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -671,19 +671,26 @@ sub setup_categories_and_bodies : Private { $bodies_to_list{ $contact->body_id } = $contact->body; + my $metas = $contact->get_metadata_for_input; + if (@$metas) { + push @{$category_extras{$contact->category}}, @$metas; + my $all_hidden = (grep { !$c->cobrand->category_extra_hidden($_) } @$metas) ? 0 : 1; + if (exists($category_extras_hidden{$contact->category})) { + $category_extras_hidden{$contact->category} &&= $all_hidden; + } else { + $category_extras_hidden{$contact->category} = $all_hidden; + } + } + + $non_public_categories{ $contact->category } = 1 if $contact->non_public; + unless ( $seen{$contact->category} ) { push @category_options, $contact; - my $metas = $contact->get_metadata_for_input; - $category_extras{$contact->category} = $metas if @$metas; - $category_extras_hidden{$contact->category} = (grep { !$c->cobrand->category_extra_hidden($_) } @$metas) ? 0 : 1; - my $body_send_method = $bodies{$contact->body_id}->send_method || ''; $c->stash->{unresponsive}{$contact->category} = $contact->body_id if !$c->stash->{unresponsive}{ALL} && ($contact->email =~ /^REFUSED$/i || $body_send_method eq 'Refused'); - - $non_public_categories{ $contact->category } = 1 if $contact->non_public; } $seen{$contact->category} = $contact; } -- cgit v1.2.3