janitor can now write suspended domains to whatever JANITOR_BLOCKLIST_OUTPUT is set to so they can be imported elsewhere (e.g., `nginx`)

staging
multiple creatures 2019-08-05 17:04:42 -05:00
parent 39a58f4061
commit 2ff40d3788
1 changed files with 10 additions and 0 deletions

View File

@ -22,6 +22,7 @@ class Scheduler::JanitorScheduler
suspend_spammers!
silence_markov!
import_blocklists!
export_suspensions!
end
private
@ -62,6 +63,15 @@ class Scheduler::JanitorScheduler
end
end
def export_suspensions!
outfile = ENV.fetch('JANITOR_BLOCKLIST_OUTPUT', '')
return if outfile.blank?
return unless File.file?(outfile)
File.open(outfile, 'w:UTF-8') do |file|
file.puts(DomainBlock.suspend.pluck(:domain))
end
end
def spammer_accounts
spammer_ids = spammer_account_ids