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

feat: poder encontrar instancias a partir de actividades

This commit is contained in:
f 2024-02-24 13:04:52 -03:00
parent a76c652f98
commit 380d484c00
No known key found for this signature in database
9 changed files with 49 additions and 14 deletions

View file

@ -5,6 +5,12 @@ class ModerationQueueController < ApplicationController
# Cola de moderación viendo todo el sitio
def index
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))
end
# Perfil remoto de usuarie

View file

@ -16,6 +16,7 @@ class ActivityPub
include ActivityPub::Concerns::JsonLdConcern
belongs_to :activity_pub
belongs_to :actor
has_one :object, through: :activity_pub
validates :activity_pub_id, presence: true

View file

@ -11,5 +11,6 @@ class ActivityPub
belongs_to :instance
has_many :activity_pubs, as: :object
has_many :activities
end
end

View file

@ -19,5 +19,9 @@ class ActivityPub
state :allowed
state :blocked
end
def uri
@uri ||= "https://#{hostname}/"
end
end
end

View file

@ -6,5 +6,12 @@ class ActivityPub
include ActivityPub::Concerns::JsonLdConcern
has_many :activity_pubs, as: :object
# Encontrar le Actor por su relación con el objeto
#
# @return [ActivityPub::Actor,nil]
def actor
ActivityPub::Actor.find_by(uri: content['actor'])
end
end
end

View file

@ -1,16 +1,12 @@
- host = instance['domain']
- host ||= instance['uri']
- hosthttps = "https://#{host}"
.row.no-gutters.pt-2
.col-1
= render 'components/checkbox', id: host
= render 'components/checkbox', id: instance.hostname
.col-11
%h4
%a{ href: hosthttps }= instance['title']
%p= instance['description'].html_safe
%p
%h4
%a{ href: instance.uri }= instance.content['title']
%p= instance.content['description'].html_safe
%p
%span= t('.users')
%span
= instance.dig('usage', 'users', 'active_month')
= instance.dig('stats', 'user_count')
= instance.content.dig('usage', 'users', 'active_month')
= instance.content.dig('stats', 'user_count')

View file

@ -7,7 +7,7 @@
-# Botones moderación
.d-flex.pb-4
= render 'components/instances_btn_box'
= render 'components/instances_btn_box', instance: instance
%hr
%h3.mt-5= t('moderation_queue.instances.title')

View file

@ -0,0 +1,18 @@
# frozen_string_literal: true
# Relaciona Actor con Activity
class AddActorToActivities < ActiveRecord::Migration[6.1]
def up
add_column :activity_pub_activities, :actor_id, :uuid, index: true
ActivityPub::Activity.find_each do |activity|
actor = ActivityPub::Actor.find_by(uri: activity.content['actor'])
activity.update(actor: actor) if actor.present?
end
end
def down
remove_column :activity_pub_activities, :actor_id, :uuid, index: true
end
end

View file

@ -484,7 +484,8 @@ CREATE TABLE public.activity_pub_activities (
activity_pub_id uuid NOT NULL,
type character varying NOT NULL,
uri character varying NOT NULL,
content jsonb DEFAULT '{}'::jsonb
content jsonb DEFAULT '{}'::jsonb,
actor_id uuid
);
@ -2472,6 +2473,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20240219204011'),
('20240219204224'),
('20240220161414'),
('20240221184007');
('20240221184007'),
('20240223170317');