mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 10:26:21 +00:00
feat: al modificar un fediblock, cambiar el estado a todes les actores
This commit is contained in:
parent
cbba822f31
commit
6c61aec60e
2 changed files with 30 additions and 1 deletions
|
@ -7,6 +7,18 @@ class ActorModeration < ApplicationRecord
|
|||
belongs_to :site
|
||||
belongs_to :actor, class_name: 'ActivityPub::Actor'
|
||||
|
||||
# Bloquea todes les Actores bloqueables
|
||||
def self.block_all!
|
||||
self.update_all(aasm_state: 'blocked', updated_at: Time.now)
|
||||
end
|
||||
|
||||
def self.pause_all!
|
||||
self.update_all(aasm_state: 'paused', updated_at: Time.now)
|
||||
end
|
||||
|
||||
# Todos los eventos de la máquina de estados
|
||||
#
|
||||
# @return [Array<Symbol>]
|
||||
def self.events
|
||||
aasm.events.map(&:name)
|
||||
end
|
||||
|
|
|
@ -37,6 +37,11 @@ class FediblockState < ApplicationRecord
|
|||
# Luego esta tarea crea las que falten e ignora las que ya se
|
||||
# bloquearon.
|
||||
ActivityPub::InstanceModerationJob.perform_now(site: site, hostnames: fediblock.hostnames)
|
||||
|
||||
# Bloquear a todes les Actores de las instancias bloqueadas para
|
||||
# indicarle a le usuarie que les tiene que desbloquear
|
||||
# manualmente.
|
||||
ActorModeration.where(actor_id: actor_ids).paused.block_all!
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,15 +57,27 @@ class FediblockState < ApplicationRecord
|
|||
disable_remotely!
|
||||
|
||||
instance_moderations.pause_all!
|
||||
|
||||
# Volver a pausar todes les actores de esta instancia que fueron
|
||||
# bloqueades.
|
||||
ActorModeration.where(actor_id: actor_ids).blocked.pause_all!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def actor_ids
|
||||
ActivityPub::Actor.where(instance_id: instance_ids).pluck(:id)
|
||||
end
|
||||
|
||||
def instance_ids
|
||||
fediblock.instances.pluck(:id)
|
||||
end
|
||||
|
||||
# Todas las instancias de moderación de este sitio
|
||||
def instance_moderations
|
||||
site.instance_moderations.where(instance_id: fediblock.instances.pluck(:id))
|
||||
site.instance_moderations.where(instance_id: instance_ids)
|
||||
end
|
||||
|
||||
# @return [Array<String>]
|
||||
|
|
Loading…
Reference in a new issue