mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-21 22:36: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]
|
||||
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
|
||||
|
||||
# Crea la actividad y la vincula con el estado
|
||||
|
|
|
@ -12,6 +12,7 @@ class ModerationQueueController < ApplicationController
|
|||
@activity_pubs = site.activity_pubs
|
||||
@instance_moderations = rubanok_process(site.instance_moderations, with: InstanceModerationProcessor)
|
||||
@actor_moderations = rubanok_process(site.actor_moderations, with: ActorModerationProcessor)
|
||||
@moderation_queue = rubanok_process(site.activity_pubs, with: ActivityPubProcessor)
|
||||
end
|
||||
|
||||
# todon.nl está usando /api/v2/instance
|
||||
|
|
|
@ -13,6 +13,7 @@ class ActivityPub < ApplicationRecord
|
|||
belongs_to :instance
|
||||
belongs_to :site
|
||||
belongs_to :object, polymorphic: true
|
||||
belongs_to :actor
|
||||
has_many :activities
|
||||
|
||||
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
|
||||
= render 'components/checkbox', id: comment['id']
|
||||
.col-11
|
||||
.row.no-gutters
|
||||
.col.col-lg-10.d-inline-flex.justify-content-between
|
||||
%h4
|
||||
%a{ href: comment['attributedTo'] }= profile['preferredUsername']
|
||||
.d-flex.flex-row.align-items-center.justify-content-between
|
||||
%h4.mb-0
|
||||
%a{ href: comment['attributedTo'] }= sanitize profile['preferredUsername']
|
||||
%small
|
||||
= render 'layouts/time', time: comment['published']
|
||||
- if comment['inReplyTo']
|
||||
.row.no-gutters
|
||||
.col.p-0
|
||||
%p
|
||||
%span= t('.reply_to')
|
||||
%span
|
||||
%a{ href: comment['inReplyTo'] }= comment['inReplyTo']
|
||||
.row.no-gutters
|
||||
.col.p-0
|
||||
- if comment['summary']
|
||||
- summary = comment['summary']
|
||||
= render 'layouts/details', summary: summary do
|
||||
%p= comment['content'].html_safe
|
||||
- else
|
||||
%p= comment['content'].html_safe
|
||||
|
||||
- if comment['inReplyTo'].present?
|
||||
%dl
|
||||
%dt.d-inline
|
||||
%small= t('.reply_to')
|
||||
%dd.d-inline
|
||||
%small
|
||||
%a{ href: comment['inReplyTo'] }= sanitize comment['inReplyTo']
|
||||
%div
|
||||
- if comment['summary'].present?
|
||||
= render 'layouts/details', summary: comment['summary'], summary_class: 'h5' do
|
||||
= sanitize comment['content']
|
||||
- else
|
||||
= sanitize comment['content']
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
.row.no-gutters.pt-2
|
||||
.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
|
||||
-# Filtros
|
||||
= render 'components/comments_filters'
|
||||
|
||||
- moderation_queue.each do |comment|
|
||||
- moderation_queue.each do |activity_pub|
|
||||
%hr
|
||||
= render 'comment', comment: comment, profile: comment['attributedTo']
|
||||
|
||||
= render 'comment', comment: activity_pub.object.content, profile: activity_pub.actor.content
|
||||
|
||||
-# Botones moderación
|
||||
.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
|
||||
%hr
|
||||
= 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
|
||||
= 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_type 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'),
|
||||
('20240228202830'),
|
||||
('20240229201155'),
|
||||
('20240301181224');
|
||||
('20240301181224'),
|
||||
('20240301202955');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue