]> git.openstreetmap.org Git - rails.git/blob - script/update-spam-blocks
Resolve erb_lint deprecations
[rails.git] / script / update-spam-blocks
1 #!/usr/bin/env ruby
2
3 require File.join(File.dirname(__FILE__), "..", "config", "environment")
4 require "generator"
5
6 addresses = User.count(
7   :conditions => {
8     :status => %w[suspended deleted],
9     :creation_time => Time.now.utc - 28.days..Time.now.utc
10   },
11   :group => :creation_address
12 )
13
14 addresses.each do |address, count|
15   next unless count > 1
16   next if Acl.exists?(:address => address)
17
18   Acl.create({
19                :address => address,
20                :k => "no_account_creation",
21                :v => "auto_spam_block"
22              }, { :without_protection => true })
23
24   puts "Blocked #{address}"
25 end
26
27 acls = Acl.find(:all, :conditions => {
28                   :k => "no_account_creation",
29                   :v => "auto_spam_block"
30                 })
31
32 acls.each do |acl|
33   next if addresses[acl.address]
34
35   acl.delete
36
37   puts "Unblocked #{acl.address}"
38 end
39
40 exit 0