mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 06:06:21 +00:00
feat: poder encontrar instancias a partir de actividades
This commit is contained in:
parent
a76c652f98
commit
380d484c00
9 changed files with 49 additions and 14 deletions
|
@ -5,6 +5,12 @@ class ModerationQueueController < ApplicationController
|
||||||
# Cola de moderación viendo todo el sitio
|
# Cola de moderación viendo todo el sitio
|
||||||
def index
|
def index
|
||||||
dummy_data
|
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
|
end
|
||||||
|
|
||||||
# Perfil remoto de usuarie
|
# Perfil remoto de usuarie
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ActivityPub
|
||||||
include ActivityPub::Concerns::JsonLdConcern
|
include ActivityPub::Concerns::JsonLdConcern
|
||||||
|
|
||||||
belongs_to :activity_pub
|
belongs_to :activity_pub
|
||||||
|
belongs_to :actor
|
||||||
has_one :object, through: :activity_pub
|
has_one :object, through: :activity_pub
|
||||||
|
|
||||||
validates :activity_pub_id, presence: true
|
validates :activity_pub_id, presence: true
|
||||||
|
|
|
@ -11,5 +11,6 @@ class ActivityPub
|
||||||
|
|
||||||
belongs_to :instance
|
belongs_to :instance
|
||||||
has_many :activity_pubs, as: :object
|
has_many :activity_pubs, as: :object
|
||||||
|
has_many :activities
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,5 +19,9 @@ class ActivityPub
|
||||||
state :allowed
|
state :allowed
|
||||||
state :blocked
|
state :blocked
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def uri
|
||||||
|
@uri ||= "https://#{hostname}/"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,5 +6,12 @@ class ActivityPub
|
||||||
include ActivityPub::Concerns::JsonLdConcern
|
include ActivityPub::Concerns::JsonLdConcern
|
||||||
|
|
||||||
has_many :activity_pubs, as: :object
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
- host = instance['domain']
|
|
||||||
- host ||= instance['uri']
|
|
||||||
- hosthttps = "https://#{host}"
|
|
||||||
|
|
||||||
.row.no-gutters.pt-2
|
.row.no-gutters.pt-2
|
||||||
.col-1
|
.col-1
|
||||||
= render 'components/checkbox', id: host
|
= render 'components/checkbox', id: instance.hostname
|
||||||
.col-11
|
.col-11
|
||||||
%h4
|
%h4
|
||||||
%a{ href: hosthttps }= instance['title']
|
%a{ href: instance.uri }= instance.content['title']
|
||||||
%p= instance['description'].html_safe
|
%p= instance.content['description'].html_safe
|
||||||
%p
|
%p
|
||||||
%span= t('.users')
|
%span= t('.users')
|
||||||
%span
|
%span
|
||||||
= instance.dig('usage', 'users', 'active_month')
|
= instance.content.dig('usage', 'users', 'active_month')
|
||||||
= instance.dig('stats', 'user_count')
|
= instance.content.dig('stats', 'user_count')
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
-# Botones moderación
|
-# Botones moderación
|
||||||
.d-flex.pb-4
|
.d-flex.pb-4
|
||||||
= render 'components/instances_btn_box'
|
= render 'components/instances_btn_box', instance: instance
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
%h3.mt-5= t('moderation_queue.instances.title')
|
%h3.mt-5= t('moderation_queue.instances.title')
|
||||||
|
|
18
db/migrate/20240223170317_add_actor_to_activities.rb
Normal file
18
db/migrate/20240223170317_add_actor_to_activities.rb
Normal 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
|
|
@ -484,7 +484,8 @@ CREATE TABLE public.activity_pub_activities (
|
||||||
activity_pub_id uuid NOT NULL,
|
activity_pub_id uuid NOT NULL,
|
||||||
type character varying NOT NULL,
|
type character varying NOT NULL,
|
||||||
uri 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'),
|
('20240219204011'),
|
||||||
('20240219204224'),
|
('20240219204224'),
|
||||||
('20240220161414'),
|
('20240220161414'),
|
||||||
('20240221184007');
|
('20240221184007'),
|
||||||
|
('20240223170317');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue