diff options
author | Matthew Somerville <matthew@mysociety.org> | 2018-06-06 16:08:24 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2018-06-06 16:08:26 +0100 |
commit | 46e17a93725087142621134686b746e6cbfb8747 (patch) | |
tree | 16410d9243c81ed0fa2d21e5321dcfe79ea59bf8 | |
parent | fb15760d8153971cce9185387c5d8ad5fc534aa7 (diff) |
Don’t delete email contacts on devolved bodies.
If we assume that any body with can_be_devolved set is probably a mix of
Open311/email, we can ignore any email address contacts for such a body.
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index 4ffd8c143..f10bdf7fb 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -320,6 +320,14 @@ sub _delete_contacts_not_in_service_list { } ); + if ($self->_current_body->can_be_devolved) { + # If the body has can_be_devolved switched on, it's most likely a + # combination of Open311/email, so ignore any email addresses. + $found_contacts = $found_contacts->search( + { email => { -not_like => '%@%' } } + ); + } + $found_contacts = $self->_delete_contacts_not_in_service_list_cobrand_overrides($found_contacts); $found_contacts->update( @@ -335,27 +343,6 @@ sub _delete_contacts_not_in_service_list { sub _delete_contacts_not_in_service_list_cobrand_overrides { my ( $self, $found_contacts ) = @_; - # for Warwickshire/Bristol/BANES, which are mixed Open311 and email, don't delete - # the email addresses - if ($self->_current_body->name eq 'Warwickshire County Council' || - $self->_current_body->name eq 'Bristol City Council' || - $self->_current_body->name eq 'Bath and North East Somerset Council') { - $found_contacts = $found_contacts->search( - { - email => { -not_like => '%@%' } - } - ); - } elsif ($self->_current_body->name eq 'East Hertfordshire District Council' || - $self->_current_body->name eq 'Stevenage Borough Council') { - # For EHDC/Stevenage we need to leave the 'Other' category alone or reports made - # in this category will be sent only to Hertfordshire County Council. - $found_contacts = $found_contacts->search( - { - category => { '!=' => 'Other' } - } - ); - } - return $found_contacts; } |