diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-08-08 09:59:14 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-08-08 12:46:17 -0500 |
commit | 4dfc40324b1f3b20550982621501e162d2ed3bed (patch) | |
tree | 1578cba8809b7db27dc82f4d439471194d5fad31 /db/migrate/20190807172051_mark_known_accounts.rb | |
parent | d019e55b7bc496d3c4d942fb4ffe65bb7e149249 (diff) |
add new `reject unknown` policy option to prevent spam & harassment from large/undermoderated servers
Diffstat (limited to 'db/migrate/20190807172051_mark_known_accounts.rb')
-rw-r--r-- | db/migrate/20190807172051_mark_known_accounts.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/migrate/20190807172051_mark_known_accounts.rb b/db/migrate/20190807172051_mark_known_accounts.rb new file mode 100644 index 000000000..95f9fe99c --- /dev/null +++ b/db/migrate/20190807172051_mark_known_accounts.rb @@ -0,0 +1,30 @@ +class MarkKnownAccounts < ActiveRecord::Migration[5.2] + def up + Rails.logger.info("Marking known accounts:") + known_accounts = local_accounts | packmates | boosted_authors | faved_authors + Rails.logger.info(" Updating account flags...") + Account.where(id: known_accounts).in_batches.update_all(known: true) + end + + private + + def boosted_authors + Rails.logger.info(" Gathering boosted accounts...") + Status.where(id: Status.local.reblogs.reorder(nil).select(:reblog_of_id)).reorder(nil).pluck(:account_id) + end + + def faved_authors + Rails.logger.info(" Gathering favourited accounts...") + Status.where(id: Favourite.select(:status_id)).reorder(nil).pluck(:account_id) + end + + def local_accounts + Rails.logger.info(" Gathering local accounts...") + Account.local.pluck(:id) + end + + def packmates + Rails.logger.info(" Gathering packmate accounts...") + Account.local.flat_map { |account| account.following_ids | account.follower_ids } + end +end |