diff --git a/app/controllers/moderation_queue_controller.rb b/app/controllers/moderation_queue_controller.rb index 5f94e1f7..8920c717 100644 --- a/app/controllers/moderation_queue_controller.rb +++ b/app/controllers/moderation_queue_controller.rb @@ -7,10 +7,8 @@ class ModerationQueueController < ApplicationController dummy_data # @todo cambiar el estado por query - @activity_pubs = site.activity_pubs.where(aasm_state: 'paused') - @activities = ActivityPub::Activity.where(activity_pub_id: @activity_pubs.pluck(:id)) - @actors = ActivityPub::Actor.where(id: @activities.unscoped.distinct.pluck(:actor_id)) - @instances = ActivityPub::Instance.where(id: @actors.distinct.pluck(:instance_id)) + @activity_pubs = site.activity_pubs + @instances = ActivityPub::Instance.where(id: @activity_pubs.distinct.pluck(:instance_id)) end # Perfil remoto de usuarie diff --git a/app/models/activity_pub.rb b/app/models/activity_pub.rb index e99fa1f4..1afeee96 100644 --- a/app/models/activity_pub.rb +++ b/app/models/activity_pub.rb @@ -10,6 +10,7 @@ class ActivityPub < ApplicationRecord include AASM + belongs_to :instance belongs_to :site belongs_to :object, polymorphic: true has_many :activities diff --git a/db/migrate/20240226133022_add_instance_id_to_activity_pubs.rb b/db/migrate/20240226133022_add_instance_id_to_activity_pubs.rb new file mode 100644 index 00000000..710aacef --- /dev/null +++ b/db/migrate/20240226133022_add_instance_id_to_activity_pubs.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Relaciona instancias con sus actividades +class AddInstanceIdToActivityPubs < ActiveRecord::Migration[6.1] + def up + add_column :activity_pubs, :instance_id, :uuid, index: true + + ActivityPub.all.find_each do |activity_pub| + activity_pub.update(instance: activity_pub&.object&.actor&.instance) + end + end + + def down + remove_column :activity_pubs, :instance_id, :uuid, index: true + end +end diff --git a/db/structure.sql b/db/structure.sql index 97e9ba36..4fb11e5a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -541,7 +541,8 @@ CREATE TABLE public.activity_pubs ( site_id bigint NOT NULL, object_id uuid NOT NULL, object_type character varying NOT NULL, - aasm_state character varying NOT NULL + aasm_state character varying NOT NULL, + instance_id uuid ); @@ -2474,6 +2475,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20240219204224'), ('20240220161414'), ('20240221184007'), -('20240223170317'); +('20240223170317'), +('20240226133022');