From 34ead9ea4a40957e4f6251c691dcc5d53e258488 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 27 Feb 2024 16:53:48 -0300 Subject: [PATCH] feat: establecer prioridades para las tareas --- app/jobs/activity_pub/actor_fetch_job.rb | 2 ++ app/jobs/activity_pub/fediblock_fetch_job.rb | 2 ++ app/jobs/activity_pub/fediblock_updated_job.rb | 2 ++ app/jobs/activity_pub/fetch_job.rb | 2 ++ app/jobs/activity_pub/instance_fetch_job.rb | 2 ++ app/jobs/activity_pub/instance_moderation_job.rb | 2 ++ 6 files changed, 12 insertions(+) diff --git a/app/jobs/activity_pub/actor_fetch_job.rb b/app/jobs/activity_pub/actor_fetch_job.rb index 1c6f1735..71107151 100644 --- a/app/jobs/activity_pub/actor_fetch_job.rb +++ b/app/jobs/activity_pub/actor_fetch_job.rb @@ -9,6 +9,8 @@ # autenticación. class ActivityPub class ActorFetchJob < ApplicationJob + self.priority = 50 + def perform(site:, actor:) ActivityPub::Actor.transaction do response = site.social_inbox.dereferencer.get(uri: actor.uri) diff --git a/app/jobs/activity_pub/fediblock_fetch_job.rb b/app/jobs/activity_pub/fediblock_fetch_job.rb index 6730cbf0..aa748bc6 100644 --- a/app/jobs/activity_pub/fediblock_fetch_job.rb +++ b/app/jobs/activity_pub/fediblock_fetch_job.rb @@ -5,6 +5,8 @@ class ActivityPub # actualizar el listado de instancias, bloquea las instancias en cada # sitio que tenga el fediblock habilitado. class FediblockFetchJob < ApplicationJob + self.priority = 50 + def perform ActivityPub::Fediblock.find_each do |fediblock| fediblock.process! diff --git a/app/jobs/activity_pub/fediblock_updated_job.rb b/app/jobs/activity_pub/fediblock_updated_job.rb index 007fa25e..b4a56609 100644 --- a/app/jobs/activity_pub/fediblock_updated_job.rb +++ b/app/jobs/activity_pub/fediblock_updated_job.rb @@ -4,6 +4,8 @@ # de los fediblocks con los sitios que las tengan activadas. class ActivityPub class FediblockUpdatedJob < ApplicationJob + self.priority = 50 + # @param :fediblock [ActivityPub::Fediblock] # @param :instances [Array] def perform(fediblock:, hostnames:) diff --git a/app/jobs/activity_pub/fetch_job.rb b/app/jobs/activity_pub/fetch_job.rb index b6c45026..e3fef993 100644 --- a/app/jobs/activity_pub/fetch_job.rb +++ b/app/jobs/activity_pub/fetch_job.rb @@ -9,6 +9,8 @@ # autenticación. class ActivityPub class FetchJob < ApplicationJob + self.priority = 50 + def perform(site:, object:) ActivityPub::Object.transaction do return if object.activity_pubs.where(aasm_state: 'removed').count.positive? diff --git a/app/jobs/activity_pub/instance_fetch_job.rb b/app/jobs/activity_pub/instance_fetch_job.rb index a5c07162..0ceb1a8a 100644 --- a/app/jobs/activity_pub/instance_fetch_job.rb +++ b/app/jobs/activity_pub/instance_fetch_job.rb @@ -3,6 +3,8 @@ class ActivityPub # Obtiene o actualiza los datos de una instancia. class InstanceFetchJob < ApplicationJob + self.priority = 100 + def perform(site:, instance:) %w[/api/v2/instance /api/v1/instance].each do |api| uri = SocialInbox.generate_uri(instance.hostname) do |u| diff --git a/app/jobs/activity_pub/instance_moderation_job.rb b/app/jobs/activity_pub/instance_moderation_job.rb index a9b0bea0..b205e68f 100644 --- a/app/jobs/activity_pub/instance_moderation_job.rb +++ b/app/jobs/activity_pub/instance_moderation_job.rb @@ -3,6 +3,8 @@ class ActivityPub # Bloquea varias instancias de una sola vez class InstanceModerationJob < ApplicationJob + self.priority = 50 + # @param :site [Site] # @param :hostnames [Array] def perform(site:, hostnames:)