5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 15:26:22 +00:00

feat: al modificar un fediblock, cambiar el estado a todes les actores

This commit is contained in:
f 2024-02-29 16:45:06 -03:00
parent cbba822f31
commit 6c61aec60e
No known key found for this signature in database
2 changed files with 30 additions and 1 deletions

View file

@ -7,6 +7,18 @@ class ActorModeration < ApplicationRecord
belongs_to :site belongs_to :site
belongs_to :actor, class_name: 'ActivityPub::Actor' 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 def self.events
aasm.events.map(&:name) aasm.events.map(&:name)
end end

View file

@ -37,6 +37,11 @@ class FediblockState < ApplicationRecord
# Luego esta tarea crea las que falten e ignora las que ya se # Luego esta tarea crea las que falten e ignora las que ya se
# bloquearon. # bloquearon.
ActivityPub::InstanceModerationJob.perform_now(site: site, hostnames: fediblock.hostnames) 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
end end
@ -52,15 +57,27 @@ class FediblockState < ApplicationRecord
disable_remotely! disable_remotely!
instance_moderations.pause_all! 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 end
end end
private 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 # Todas las instancias de moderación de este sitio
def instance_moderations def instance_moderations
site.instance_moderations.where(instance_id: fediblock.instances.pluck(:id)) site.instance_moderations.where(instance_id: instance_ids)
end end
# @return [Array<String>] # @return [Array<String>]