Email Blacklist - Bulk Delete/Disable Question

After the domains are blacklisted, the accounts that have already made it through are unaffected and can still be used.

I want to ask if anyone knows of a way to bulk destroy (delete user + all of their content), suspend or silence users based on their registration email domain?

In my case this would allow deleting/disabling hundreds of thousands of accounts that used the catchall domain technique to register.

Was this migrated data? Deleting that many accounts is going to be very, very painful – unless they all have almost no content.

إعجاب واحد (1)

You can do it from the rails console, but it does sound like it could be very messy.

إعجاب واحد (1)

@codinghorror - It’s not migrated data. I don’t mind painful and slow as the alternative of allowing the accounts to stay is probably worse :hot_face: For amounts of content, it’s a mix, some have none (usually the spammers intend to use these accounts later), some have minimal, some have heaps.

@pfaffman Great! Do you know how? Haha :pray:

إعجاب واحد (1)

Have you given a thought to anonymizing the users?

إعجاب واحد (1)

@fzngagan That might be a solid solution. Know if there a way to do this in bulk?

إعجاب واحد (1)

Yes. It can be done from the rails console. But the question is, on what criteria do you want to anonymize them?

إعجاب واحد (1)

@fzngagan Great! The criteria would be, all emails that use a specific domain in their registration email. E.g. example@blacklisted.com, example2@blacklisted.com

إعجاب واحد (1)

In rails console, type these commands and see if they give expected results(replace you email id pattern with ‘@gmail.com’)

idlist = UserEmail.where("email like '%@gmail.com'").pluck(:user_id)
users = User.find(idlist)

then (proceed with caution)

system_user = Discourse.system_user
users.each do |user|
  UserAnonymizer.new(user, system_user).make_anonymous
end

I’m not an expert in performance related stuff, so I don’t know exactly what would happen if number of users is big.

إعجابَين (2)

@fzngagan Wow nice, thanks heaps! :slight_smile: I really appreciate it.

I’ll make sure everything is recently backed up before giving this a shot.

Quick question, do you know if bulk silencing the users (forever) using this technique is possible?

إعجاب واحد (1)

Yes. Rails console can do mostly everything that can be done from code.

إعجابَين (2)