mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Move account sensitize-related methods to concern
This commit is contained in:
parent
2ed13071ef
commit
c6782c941e
2 changed files with 22 additions and 13 deletions
|
@ -85,6 +85,7 @@ class Account < ApplicationRecord
|
||||||
include Account::Interactions
|
include Account::Interactions
|
||||||
include Account::Merging
|
include Account::Merging
|
||||||
include Account::Search
|
include Account::Search
|
||||||
|
include Account::Sensitizes
|
||||||
include Account::StatusesSearch
|
include Account::StatusesSearch
|
||||||
include DomainMaterializable
|
include DomainMaterializable
|
||||||
include DomainNormalizable
|
include DomainNormalizable
|
||||||
|
@ -121,7 +122,6 @@ class Account < ApplicationRecord
|
||||||
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
||||||
scope :silenced, -> { where.not(silenced_at: nil) }
|
scope :silenced, -> { where.not(silenced_at: nil) }
|
||||||
scope :suspended, -> { where.not(suspended_at: nil) }
|
scope :suspended, -> { where.not(suspended_at: nil) }
|
||||||
scope :sensitized, -> { where.not(sensitized_at: nil) }
|
|
||||||
scope :without_suspended, -> { where(suspended_at: nil) }
|
scope :without_suspended, -> { where(suspended_at: nil) }
|
||||||
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) }
|
||||||
|
@ -276,18 +276,6 @@ class Account < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sensitized?
|
|
||||||
sensitized_at.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def sensitize!(date = Time.now.utc)
|
|
||||||
update!(sensitized_at: date)
|
|
||||||
end
|
|
||||||
|
|
||||||
def unsensitize!
|
|
||||||
update!(sensitized_at: nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
def memorialize!
|
def memorialize!
|
||||||
update!(memorial: true)
|
update!(memorial: true)
|
||||||
end
|
end
|
||||||
|
|
21
app/models/concerns/account/sensitizes.rb
Normal file
21
app/models/concerns/account/sensitizes.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Account::Sensitizes
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
scope :sensitized, -> { where.not(sensitized_at: nil) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def sensitized?
|
||||||
|
sensitized_at.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def sensitize!(date = Time.now.utc)
|
||||||
|
update!(sensitized_at: date)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsensitize!
|
||||||
|
update!(sensitized_at: nil)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue