diff options
Diffstat (limited to 'perllib/Open311')
-rw-r--r-- | perllib/Open311/GetServiceRequests.pm | 6 | ||||
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 17 |
2 files changed, 22 insertions, 1 deletions
diff --git a/perllib/Open311/GetServiceRequests.pm b/perllib/Open311/GetServiceRequests.pm index 194d8d296..a9ec88a70 100644 --- a/perllib/Open311/GetServiceRequests.pm +++ b/perllib/Open311/GetServiceRequests.pm @@ -146,7 +146,8 @@ sub create_problems { next; } - if ( my $cobrand = $body->get_cobrand_handler ) { + my $cobrand = $body->get_cobrand_handler; + if ( $cobrand ) { my $filtered = $cobrand->call_hook('filter_report_description', $request->{description}); $request->{description} = $filtered if defined $filtered; } @@ -157,6 +158,7 @@ sub create_problems { my $state = $open311->map_state($request->{status}); my $non_public = $request->{non_public} ? 1 : 0; + $non_public ||= $contacts[0] ? $contacts[0]->non_public : 0; my $problem = $self->schema->resultset('Problem')->new( { @@ -184,6 +186,8 @@ sub create_problems { } ); + next if $cobrand && $cobrand->call_hook(open311_skip_report_fetch => $problem); + $open311->add_media($request->{media_url}, $problem) if $request->{media_url}; diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index ad7288c62..2da67e9cd 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -165,6 +165,7 @@ sub _handle_existing_contact { } $self->_set_contact_group($contact); + $self->_set_contact_non_public($contact); push @{ $self->found_contacts }, $self->_current_service->{service_code}; } @@ -201,6 +202,7 @@ sub _create_contact { } $self->_set_contact_group($contact); + $self->_set_contact_non_public($contact); if ( $contact ) { push @{ $self->found_contacts }, $self->_current_service->{service_code}; @@ -283,6 +285,21 @@ sub _set_contact_group { } } +sub _set_contact_non_public { + my ($self, $contact) = @_; + + # We never want to make a private category unprivate. + return if $contact->non_public; + + my %keywords = map { $_ => 1 } split /,/, ( $self->_current_service->{keywords} || '' ); + $contact->update({ + non_public => 1, + editor => $0, + whenedited => \'current_timestamp', + note => 'marked private automatically by script', + }) if $keywords{private}; +} + sub _delete_contacts_not_in_service_list { my $self = shift; |