Anonymized Discourse Users Should Have Email Digests Set to False

Noticed that when a Discourse user is "anonymized" their user option to receive email digests is not set to "false". This causes the Discourse job scheduler to attempt to send digest emails to users with invalid email addresses:

Seem a good idea to add this:

UserOption.where(user_id: @user_id).update(email_digests: false)

to this module:

discourse/app/jobs/regular/anonymize_user.rb 

Reason:

Currently, when a user is anonymized the job scheduler skips these users because of invalid email addresses (and logs these skipped jobs as well), which we can see in the admin panel:

Instead of "skipping based on an invalid email address", it seems more efficient (and less log clutter) to simply disable email digests in the user option when the user is anonymized.

Unless I missed it somewhere, the email_digests user option is not currently set to false when a user is anonymized:

I offered to push a PR to Discourse core here, but no replies so far:

https://meta.discourse.org/t/set-useroption-email-digests-false-in-class-anonymizeuser/171554

def update_user_options
   UserOption.where(user_id: @user_id).update(email_digests: false)
end

plus a small addition to execute

def execute(args)
      @user_id = args[:user_id]
      @prev_email = args[:prev_email]
      @anonymize_ip = args[:anonymize_ip]

      make_anonymous
      update_user_options
end

EXTRA?

While we are in that module, we could also consider setting hide_profile_and_presence: true maybe?

def update_user_options
   UserOption.where(user_id: @user_id).update(email_digests: false, hide_profile_and_presence: true)
end

STATUS

This seems best to fix in the core Discourse code and not in a plugin; and it's actually a lot more important to fix this "omission" that many of the nits and small user view issues we see in meta. So far, no one has responded, but that could be because it is a holiday weekend.

2 Likes