2024-02-27 19:40:08 +00:00
|
|
|
# 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
|
2024-02-27 19:53:48 +00:00
|
|
|
self.priority = 50
|
|
|
|
|
2024-02-27 19:40:08 +00:00
|
|
|
# @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
|