]> git.openstreetmap.org Git - rails.git/blob - script/update-spam-blocks
Don't show "Load More" if we found less than 20 changesets
[rails.git] / script / update-spam-blocks
1 #!/usr/bin/env ruby
2
3 require File.dirname(__FILE__) + '/../config/environment'
4 require 'generator'
5
6 addresses = User.count(
7   :conditions => {
8     :status => ["suspended", "deleted"],
9     :creation_time => Time.now - 28.days .. Time.now
10   },
11   :group => :creation_ip
12 )
13
14 addresses.each do |address,count|
15   if count > 1
16     acl = Acl.find(:first, :conditions => {
17       :address => address,
18     })
19
20     unless acl
21       Acl.create({
22         :address => address,
23         :k => "no_account_creation",
24         :v => "auto_spam_block"
25       }, :without_protection => true)
26
27       puts "Blocked #{address}"
28     end
29   end
30 end
31
32 acls = Acl.find(:all, :conditions => {
33   :k => "no_account_creation",
34   :v => "auto_spam_block"
35 })
36
37 acls.each do |acl|
38   unless addresses[acl.address]
39     acl.delete
40
41     puts "Unblocked #{acl.address}"
42   end
43 end
44
45 exit 0