0
0
Fork 0

Move account silence-related methods to concern (#28866)

This commit is contained in:
Matt Jankowski 2024-11-11 03:29:55 -05:00 committed by GitHub
parent 157fba4698
commit d033920b7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 41 additions and 22 deletions

View file

@ -90,6 +90,7 @@ class Account < ApplicationRecord
include Account::Interactions
include Account::Merging
include Account::Search
include Account::Silences
include Account::StatusesSearch
include Account::Suspensions
include Account::AttributionDomains
@ -129,9 +130,7 @@ class Account < ApplicationRecord
scope :remote, -> { where.not(domain: nil) }
scope :local, -> { where(domain: nil) }
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
scope :silenced, -> { where.not(silenced_at: nil) }
scope :sensitized, -> { where.not(sensitized_at: nil) }
scope :without_silenced, -> { where(silenced_at: nil) }
scope :without_instance_actor, -> { where.not(id: INSTANCE_ACTOR_ID) }
scope :recent, -> { reorder(id: :desc) }
scope :bots, -> { where(actor_type: AUTOMATED_ACTOR_TYPES) }
@ -244,18 +243,6 @@ class Account < ApplicationRecord
ResolveAccountService.new.call(acct) unless local?
end
def silenced?
silenced_at.present?
end
def silence!(date = Time.now.utc)
update!(silenced_at: date)
end
def unsilence!
update!(silenced_at: nil)
end
def sensitized?
sensitized_at.present?
end

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
module Account::Silences
extend ActiveSupport::Concern
included do
scope :silenced, -> { where.not(silenced_at: nil) }
scope :without_silenced, -> { where(silenced_at: nil) }
end
def silenced?
silenced_at.present?
end
def silence!(date = Time.now.utc)
update!(silenced_at: date)
end
def unsilence!
update!(silenced_at: nil)
end
end