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

feat: relacionar actividades con instancias de origen

This commit is contained in:
f 2024-02-26 10:39:00 -03:00
parent 380d484c00
commit 64cef8a13e
No known key found for this signature in database
4 changed files with 23 additions and 6 deletions

View file

@ -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

View file

@ -10,6 +10,7 @@
class ActivityPub < ApplicationRecord
include AASM
belongs_to :instance
belongs_to :site
belongs_to :object, polymorphic: true
has_many :activities

View file

@ -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

View file

@ -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');