Move account silence-related methods to concern (#28866)
This commit is contained in:
parent
157fba4698
commit
d033920b7e
4 changed files with 41 additions and 22 deletions
22
app/models/concerns/account/silences.rb
Normal file
22
app/models/concerns/account/silences.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue