mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-29 20:56:22 +00:00
feat: moderar en la social inbox
This commit is contained in:
parent
6eaf00c7ad
commit
6d9a64f728
2 changed files with 46 additions and 2 deletions
|
@ -13,5 +13,16 @@ class ActivityPub
|
||||||
has_many :actor_moderation
|
has_many :actor_moderation
|
||||||
has_many :activity_pubs, as: :object
|
has_many :activity_pubs, as: :object
|
||||||
has_many :activities
|
has_many :activities
|
||||||
|
|
||||||
|
# Obtiene el nombre de la Actor como mención, solo si obtuvimos el
|
||||||
|
# contenido de antemano.
|
||||||
|
#
|
||||||
|
# @return [String, nil]
|
||||||
|
def mention
|
||||||
|
return if content['preferredUsername'].blank?
|
||||||
|
return if instance.blank?
|
||||||
|
|
||||||
|
@mention ||= "@#{content['preferredUsername']}@#{instance.hostname}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,18 +15,51 @@ class ActorModeration < ApplicationRecord
|
||||||
|
|
||||||
event :pause do
|
event :pause do
|
||||||
transitions from: %i[allowed blocked reported], to: :paused
|
transitions from: %i[allowed blocked reported], to: :paused
|
||||||
|
|
||||||
|
before do
|
||||||
|
pause_remotely!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
event :allowed do
|
event :allow do
|
||||||
transitions from: %i[paused blocked reported], to: :allowed
|
transitions from: %i[paused blocked reported], to: :allowed
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow_remotely!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
event :blocked do
|
event :block do
|
||||||
transitions from: %i[paused allowed], to: :blocked
|
transitions from: %i[paused allowed], to: :blocked
|
||||||
|
|
||||||
|
before do
|
||||||
|
block_remotely!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
event :reported do
|
event :reported do
|
||||||
transitions from: %i[blocked], to: :reported
|
transitions from: %i[blocked], to: :reported
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pause_remotely!
|
||||||
|
raise AASM::InvalidTransition unless
|
||||||
|
actor.mention &&
|
||||||
|
site.social_inbox.allowlist.delete(list: [actor.mention]).ok? &&
|
||||||
|
site.social_inbox.blocklist.delete(list: [actor.mention]).ok?
|
||||||
|
end
|
||||||
|
|
||||||
|
def allow_remotely!
|
||||||
|
raise AASM::InvalidTransition unless
|
||||||
|
actor.mention &&
|
||||||
|
site.social_inbox.allowlist.post(list: [actor.mention]).ok? &&
|
||||||
|
site.social_inbox.blocklist.delete(list: [actor.mention]).ok?
|
||||||
|
end
|
||||||
|
|
||||||
|
def block_remotely!
|
||||||
|
raise AASM::InvalidTransition unless
|
||||||
|
actor.mention &&
|
||||||
|
site.social_inbox.allowlist.delete(list: [actor.mention]).ok? &&
|
||||||
|
site.social_inbox.blocklist.post(list: [actor.mention]).ok?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue