From f2ef45fb4ed8e167a0dea3bba1a9cd1ad640a31c Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 1 Jun 2020 11:06:55 +0100 Subject: Ignore body users when anonymizing. --- perllib/FixMyStreet/Script/Inactive.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'perllib/FixMyStreet/Script/Inactive.pm') diff --git a/perllib/FixMyStreet/Script/Inactive.pm b/perllib/FixMyStreet/Script/Inactive.pm index 8dd524ce1..4d28057d4 100644 --- a/perllib/FixMyStreet/Script/Inactive.pm +++ b/perllib/FixMyStreet/Script/Inactive.pm @@ -158,8 +158,14 @@ sub delete_reports { sub anonymize_users { my $self = shift; + my $body_users = FixMyStreet::DB->resultset("Body")->search({ + comment_user_id => { '!=' => undef }, + }, { + columns => 'comment_user_id', + }); my $users = FixMyStreet::DB->resultset("User")->search({ last_active => { '<', interval($self->anonymize) }, + id => { -not_in => $body_users->as_query }, email => { -not_like => 'removed-%@' . FixMyStreet->config('EMAIL_DOMAIN') }, }); -- cgit v1.2.3 From 251acf7799e78fd46a39154f0381c7470d5542a9 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 11 Jun 2020 17:25:49 +0100 Subject: Skip accounts without email for inactive emails. --- perllib/FixMyStreet/Script/Inactive.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'perllib/FixMyStreet/Script/Inactive.pm') diff --git a/perllib/FixMyStreet/Script/Inactive.pm b/perllib/FixMyStreet/Script/Inactive.pm index 4d28057d4..6b3372a2b 100644 --- a/perllib/FixMyStreet/Script/Inactive.pm +++ b/perllib/FixMyStreet/Script/Inactive.pm @@ -185,6 +185,7 @@ sub email_inactive_users { }); while (my $user = $users->next) { next if $user->get_extra_metadata('inactive_email_sent'); + next unless $user->email && $user->email_verified; say "Emailing user #" . $user->id if $self->verbose; next if $self->dry_run; -- cgit v1.2.3