mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 14:56:22 +00:00
25 lines
899 B
Ruby
25 lines
899 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
# Se encarga de mantener sincronizadas las listas de instancias
|
||
|
# de los fediblocks con los sitios que las tengan activadas.
|
||
|
class ActivityPub
|
||
|
class FediblockUpdatedJob < ApplicationJob
|
||
|
# @param :fediblock [ActivityPub::Fediblock]
|
||
|
# @param :instances [Array<String>]
|
||
|
def perform(fediblock:, hostnames:)
|
||
|
instances = ActivityPub::Instance.where(hostname: instances)
|
||
|
|
||
|
# Todos los sitios con la Social Inbox habilitada
|
||
|
Site.where(id: DeploySocialDistributedPress.pluck(:site_id)).find_each do |site|
|
||
|
# Crea el estado si no existía
|
||
|
fediblock_state = site.fediblock_states.find_or_create_by(fediblock: fediblock)
|
||
|
|
||
|
# No hace nada con los deshabilitados
|
||
|
next unless fediblock_state.enabled?
|
||
|
|
||
|
ActivityPub::InstanceModerationJob.perform_later(site: site, hostnames: instances)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|