域名被列入黑名单后,已通过验证的账户不受影响,仍可继续使用。
我想请教一下,是否有人知道如何根据注册邮箱域名批量销毁(删除用户及其所有内容)、暂停或禁言用户?
在我的情况下,这将允许删除或禁用数十万个利用通配符域名技术注册的账户。
域名被列入黑名单后,已通过验证的账户不受影响,仍可继续使用。
我想请教一下,是否有人知道如何根据注册邮箱域名批量销毁(删除用户及其所有内容)、暂停或禁言用户?
在我的情况下,这将允许删除或禁用数十万个利用通配符域名技术注册的账户。
Was this migrated data? Deleting that many accounts is going to be very, very painful – unless they all have almost no content.
You can do it from the rails console, but it does sound like it could be very messy.
@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
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 
Have you given a thought to anonymizing the users?
@fzngagan That might be a solid solution. Know if there a way to do this in bulk?
Yes. It can be done from the rails console. But the question is, on what criteria do you want to anonymize them?
@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
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.
@fzngagan Wow nice, thanks heaps!
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?
Yes. Rails console can do mostly everything that can be done from code.