mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 04:26:22 +00:00
feat: comentarios por actore
This commit is contained in:
parent
85c45d4823
commit
b255acf2fd
9 changed files with 62 additions and 30 deletions
|
@ -134,7 +134,7 @@ module Api
|
||||||
#
|
#
|
||||||
# @return [ActivityPub]
|
# @return [ActivityPub]
|
||||||
def activity_pub
|
def activity_pub
|
||||||
@activity_pub ||= site.activity_pubs.find_or_create_by!(site: site, instance: instance, object_id: object.id, object_type: object.type)
|
@activity_pub ||= site.activity_pubs.find_or_create_by!(site: site, actor: actor, instance: instance, object_id: object.id, object_type: object.type)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Crea la actividad y la vincula con el estado
|
# Crea la actividad y la vincula con el estado
|
||||||
|
|
|
@ -12,6 +12,7 @@ class ModerationQueueController < ApplicationController
|
||||||
@activity_pubs = site.activity_pubs
|
@activity_pubs = site.activity_pubs
|
||||||
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)
|
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)
|
||||||
@actor_moderations = rubanok_process(site.actor_moderations, with: ActorModerationProcessor)
|
@actor_moderations = rubanok_process(site.actor_moderations, with: ActorModerationProcessor)
|
||||||
|
@moderation_queue = rubanok_process(site.activity_pubs, with: ActivityPubProcessor)
|
||||||
end
|
end
|
||||||
|
|
||||||
# todon.nl está usando /api/v2/instance
|
# todon.nl está usando /api/v2/instance
|
||||||
|
|
|
@ -13,6 +13,7 @@ class ActivityPub < ApplicationRecord
|
||||||
belongs_to :instance
|
belongs_to :instance
|
||||||
belongs_to :site
|
belongs_to :site
|
||||||
belongs_to :object, polymorphic: true
|
belongs_to :object, polymorphic: true
|
||||||
|
belongs_to :actor
|
||||||
has_many :activities
|
has_many :activities
|
||||||
|
|
||||||
validates :site_id, presence: true
|
validates :site_id, presence: true
|
||||||
|
|
15
app/processors/activity_pub_processor.rb
Normal file
15
app/processors/activity_pub_processor.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Gestiona los filtros de ActivityPub
|
||||||
|
class ActivityPubProcessor < Rubanok::Processor
|
||||||
|
# En orden descendiente para encontrar la última actividad
|
||||||
|
#
|
||||||
|
# Por ahora solo queremos moderar comentarios.
|
||||||
|
prepare do
|
||||||
|
raw.where(object_type: %w[ActivityPub::Object::Note ActivityPub::Object::Article]).order(updated_at: :desc)
|
||||||
|
end
|
||||||
|
|
||||||
|
map :activity_pub_state, activate_always: true do |activity_pub_state: 'paused'|
|
||||||
|
raw.where(aasm_state: activity_pub_state)
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,24 +4,21 @@
|
||||||
.col-1
|
.col-1
|
||||||
= render 'components/checkbox', id: comment['id']
|
= render 'components/checkbox', id: comment['id']
|
||||||
.col-11
|
.col-11
|
||||||
.row.no-gutters
|
.d-flex.flex-row.align-items-center.justify-content-between
|
||||||
.col.col-lg-10.d-inline-flex.justify-content-between
|
%h4.mb-0
|
||||||
%h4
|
%a{ href: comment['attributedTo'] }= sanitize profile['preferredUsername']
|
||||||
%a{ href: comment['attributedTo'] }= profile['preferredUsername']
|
%small
|
||||||
= render 'layouts/time', time: comment['published']
|
= render 'layouts/time', time: comment['published']
|
||||||
- if comment['inReplyTo']
|
- if comment['inReplyTo'].present?
|
||||||
.row.no-gutters
|
%dl
|
||||||
.col.p-0
|
%dt.d-inline
|
||||||
%p
|
%small= t('.reply_to')
|
||||||
%span= t('.reply_to')
|
%dd.d-inline
|
||||||
%span
|
%small
|
||||||
%a{ href: comment['inReplyTo'] }= comment['inReplyTo']
|
%a{ href: comment['inReplyTo'] }= sanitize comment['inReplyTo']
|
||||||
.row.no-gutters
|
%div
|
||||||
.col.p-0
|
- if comment['summary'].present?
|
||||||
- if comment['summary']
|
= render 'layouts/details', summary: comment['summary'], summary_class: 'h5' do
|
||||||
- summary = comment['summary']
|
= sanitize comment['content']
|
||||||
= render 'layouts/details', summary: summary do
|
- else
|
||||||
%p= comment['content'].html_safe
|
= sanitize comment['content']
|
||||||
- else
|
|
||||||
%p= comment['content'].html_safe
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
.row.no-gutters.pt-2
|
.row.no-gutters.pt-2
|
||||||
.col-1.d-flex.align-items-center
|
.col-1.d-flex.align-items-center
|
||||||
= render 'components/checkbox', id: moderation_queue.first['id']
|
= render 'components/select_all', id: 'select-all-comments'
|
||||||
.col-md-9
|
.col-md-9
|
||||||
-# Filtros
|
-# Filtros
|
||||||
= render 'components/comments_filters'
|
= render 'components/comments_filters'
|
||||||
|
|
||||||
- moderation_queue.each do |comment|
|
- moderation_queue.each do |activity_pub|
|
||||||
%hr
|
%hr
|
||||||
= render 'comment', comment: comment, profile: comment['attributedTo']
|
= render 'comment', comment: activity_pub.object.content, profile: activity_pub.actor.content
|
||||||
|
|
||||||
-# Botones moderación
|
-# Botones moderación
|
||||||
.d-flex.justify-content-center
|
.d-flex.justify-content-center
|
||||||
= render 'components/comments_btn_box', comment: comment
|
= render 'components/comments_btn_box', comment: activity_pub.object.content
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
= render 'moderation_queue/instances', site: @site, instance_moderations: @instance_moderations, fediblock_states: @site.fediblock_states
|
= render 'moderation_queue/instances', site: @site, instance_moderations: @instance_moderations, fediblock_states: @site.fediblock_states
|
||||||
%hr
|
%hr
|
||||||
= render 'layouts/details', id: 'accounts', summary: t('.accounts') do
|
= render 'layouts/details', id: 'accounts', summary: t('.accounts') do
|
||||||
= render 'moderation_queue/accounts', site: @site, post: @post, actor_moderations: @actor_moderations
|
= render 'moderation_queue/accounts', site: @site, actor_moderations: @actor_moderations
|
||||||
%hr
|
%hr
|
||||||
= render 'layouts/details', id: 'comments', summary: t('.comments') do
|
= render 'layouts/details', id: 'comments', summary: t('.comments') do
|
||||||
= render 'moderation_queue/comments', site: @site, post: @post, moderation_queue: @moderation_queue
|
= render 'moderation_queue/comments', site: @site, moderation_queue: @moderation_queue
|
||||||
|
|
16
db/migrate/20240301202955_add_actor_id_to_activity_pubs.rb
Normal file
16
db/migrate/20240301202955_add_actor_id_to_activity_pubs.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Relaciona estados de actividades con les actores que las hicieron
|
||||||
|
class AddActorIdToActivityPubs < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
add_column :activity_pubs, :actor_id, :uuid
|
||||||
|
|
||||||
|
ActivityPub.all.find_each do |activity_pub|
|
||||||
|
activity_pub.update_column(:actor_id, activity_pub.activities.last.actor_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :activity_pubs, :actor_id
|
||||||
|
end
|
||||||
|
end
|
|
@ -572,7 +572,8 @@ CREATE TABLE public.activity_pubs (
|
||||||
object_id uuid NOT NULL,
|
object_id uuid NOT NULL,
|
||||||
object_type character varying NOT NULL,
|
object_type character varying NOT NULL,
|
||||||
aasm_state character varying NOT NULL,
|
aasm_state character varying NOT NULL,
|
||||||
instance_id uuid
|
instance_id uuid,
|
||||||
|
actor_id uuid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2699,6 +2700,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20240228171335'),
|
('20240228171335'),
|
||||||
('20240228202830'),
|
('20240228202830'),
|
||||||
('20240229201155'),
|
('20240229201155'),
|
||||||
('20240301181224');
|
('20240301181224'),
|
||||||
|
('20240301202955');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue