mirror of
https://github.com/mastodon/mastodon
synced 2024-11-27 14:28:24 +09:00
Extract Account::AUTOMATED_ACTOR_TYPES
for "bot" actor_type values (#31772)
This commit is contained in:
parent
cc4865193a
commit
be77a1098b
@ -75,6 +75,8 @@ class Account < ApplicationRecord
|
|||||||
DISPLAY_NAME_LENGTH_LIMIT = 30
|
DISPLAY_NAME_LENGTH_LIMIT = 30
|
||||||
NOTE_LENGTH_LIMIT = 500
|
NOTE_LENGTH_LIMIT = 500
|
||||||
|
|
||||||
|
AUTOMATED_ACTOR_TYPES = %w(Application Service).freeze
|
||||||
|
|
||||||
include Attachmentable # Load prior to Avatar & Header concerns
|
include Attachmentable # Load prior to Avatar & Header concerns
|
||||||
|
|
||||||
include Account::Associations
|
include Account::Associations
|
||||||
@ -127,7 +129,8 @@ class Account < ApplicationRecord
|
|||||||
scope :without_silenced, -> { where(silenced_at: nil) }
|
scope :without_silenced, -> { where(silenced_at: nil) }
|
||||||
scope :without_instance_actor, -> { where.not(id: INSTANCE_ACTOR_ID) }
|
scope :without_instance_actor, -> { where.not(id: INSTANCE_ACTOR_ID) }
|
||||||
scope :recent, -> { reorder(id: :desc) }
|
scope :recent, -> { reorder(id: :desc) }
|
||||||
scope :bots, -> { where(actor_type: %w(Application Service)) }
|
scope :bots, -> { where(actor_type: AUTOMATED_ACTOR_TYPES) }
|
||||||
|
scope :non_automated, -> { where.not(actor_type: AUTOMATED_ACTOR_TYPES) }
|
||||||
scope :groups, -> { where(actor_type: 'Group') }
|
scope :groups, -> { where(actor_type: 'Group') }
|
||||||
scope :alphabetic, -> { order(domain: :asc, username: :asc) }
|
scope :alphabetic, -> { order(domain: :asc, username: :asc) }
|
||||||
scope :matches_uri_prefix, ->(value) { where(arel_table[:uri].matches("#{sanitize_sql_like(value)}/%", false, true)).or(where(uri: value)) }
|
scope :matches_uri_prefix, ->(value) { where(arel_table[:uri].matches("#{sanitize_sql_like(value)}/%", false, true)).or(where(uri: value)) }
|
||||||
@ -183,7 +186,7 @@ class Account < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bot?
|
def bot?
|
||||||
%w(Application Service).include? actor_type
|
AUTOMATED_ACTOR_TYPES.include?(actor_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def instance_actor?
|
def instance_actor?
|
||||||
|
@ -502,7 +502,7 @@ module Mastodon::CLI
|
|||||||
- not muted/blocked by us
|
- not muted/blocked by us
|
||||||
LONG_DESC
|
LONG_DESC
|
||||||
def prune
|
def prune
|
||||||
query = Account.remote.where.not(actor_type: %i(Application Service))
|
query = Account.remote.non_automated
|
||||||
query = query.where('NOT EXISTS (SELECT 1 FROM mentions WHERE account_id = accounts.id)')
|
query = query.where('NOT EXISTS (SELECT 1 FROM mentions WHERE account_id = accounts.id)')
|
||||||
query = query.where('NOT EXISTS (SELECT 1 FROM favourites WHERE account_id = accounts.id)')
|
query = query.where('NOT EXISTS (SELECT 1 FROM favourites WHERE account_id = accounts.id)')
|
||||||
query = query.where('NOT EXISTS (SELECT 1 FROM statuses WHERE account_id = accounts.id)')
|
query = query.where('NOT EXISTS (SELECT 1 FROM statuses WHERE account_id = accounts.id)')
|
||||||
|
Loading…
Reference in New Issue
Block a user