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

feat: acciones sobre comentarios

This commit is contained in:
f 2024-03-04 13:49:07 -03:00
parent d8487ea7e9
commit 5fabe9cd83
No known key found for this signature in database
11 changed files with 82 additions and 33 deletions

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
# Gestiona acciones de moderación
class ActivityPubsController < ApplicationController
ActivityPub.events.each do |event|
define_method(event) do
activity_pub.public_send(:"#{event}!") if activity_pub.public_send(:"may_#{event}?")
redirect_back fallback_location: site_moderation_queue_path(**(session[:moderation_queue_filters] || {}))
end
end
def action_on_several
end
private
def activity_pub
@activity_pub ||= site.activity_pubs.find(params[:activity_pub_id])
end
end

View file

@ -9,6 +9,9 @@
# @see {https://www.w3.org/TR/activitypub/#client-to-server-interactions}
class ActivityPub < ApplicationRecord
include AASM
include AasmEventsConcern
IGNORED_EVENTS = %i[remove]
belongs_to :instance
belongs_to :site

View file

@ -3,6 +3,9 @@
# Mantiene la relación entre Site y Actor
class ActorModeration < ApplicationRecord
include AASM
include AasmEventsConcern
IGNORED_EVENTS = []
belongs_to :site
belongs_to :remote_flag, class_name: 'ActivityPub::RemoteFlag'
@ -19,13 +22,6 @@ class ActorModeration < ApplicationRecord
self.update_all(aasm_state: 'paused', updated_at: Time.now)
end
# Todos los eventos de la máquina de estados
#
# @return [Array<Symbol>]
def self.events
aasm.events.map(&:name)
end
aasm do
state :paused, initial: true
state :allowed

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
module AasmEventsConcern
extend ActiveSupport::Concern
included do
# Todos los eventos de la máquina de estados
#
# @return [Array<Symbol>]
def self.events
aasm.events.map(&:name) - self::IGNORED_EVENTS
end
end
end

View file

@ -1,6 +1,7 @@
-# Componente Botón general Moderación
- local_assigns[:method] ||= 'patch'
- local_assigns[:class] ||= 'btn-secondary'
- local_assigns[:class] = "btn #{local_assigns[:class]}"
-# @todo path es obligatorio

View file

@ -1,8 +1,8 @@
-# Componente Botonera de Comentarios
- btn_class = 'btn-secondary py-1 px-2'
= render 'components/btn_base', text: t('.text_pause'), class: btn_class, href: ''
= render 'components/btn_base', text: t('.text_reject'), class: btn_class, href: ''
= render 'components/btn_base', text: t('.text_accept'), class: btn_class, href: ''
= render 'components/btn_base', text: t('.text_reply'), class: btn_class, href: ''
= render 'components/btn_base', text: t('.text_report'), class: btn_class, href: ''
.d-flex.flex-row
- ActivityPub.events.each do |event|
= render 'components/btn_base',
text: t(".text_#{event}"),
path: public_send(:"site_activity_pub_#{event}_path", activity_pub_id: activity_pub),
disabled: !activity_pub.public_send(:"may_#{event}?")

View file

@ -1,11 +1,16 @@
-# Componente Comentario
-#
Componente Comentario
@param profile [Hash]
@param comment [Hash]
@param activity_pub [ActivityPub]
- in_reply_to = text_plain comment['inReplyTo']
- summary = text_plain(comment['summary'])
- summary = text_plain comment['summary']
.row.no-gutters
.col-1
= render 'components/checkbox', id: comment['id']
= render 'components/checkbox', id: activity_pub.id, name: 'activity_pub[]', value: activity_pub.id, data: { target: 'select-all.input' }
.col-11
.d-flex.flex-row.align-items-center.justify-content-between
%h4.mb-0
@ -25,3 +30,4 @@
= sanitize comment['content']
- else
= sanitize comment['content']
= render 'components/comments_btn_box', activity_pub: activity_pub

View file

@ -1,3 +1,4 @@
%form{ action: site_activity_pubs_action_on_several_path, method: :post, data: { controller: 'select-all' } }
.row.no-gutters.pt-2
.col-1.d-flex.align-items-center
= render 'components/select_all', id: 'select-all-comments'
@ -5,10 +6,9 @@
-# Filtros
= render 'components/comments_filters'
- if moderation_queue.count.zero?
%h4= t('moderation_queue.nothing')
- moderation_queue.each do |activity_pub|
- cache [activity_pub, activity_pub.object, activity_pub.actor] do
%hr
= 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: activity_pub.object.content
= render 'comment', comment: activity_pub.object.content, profile: activity_pub.actor.content, activity_pub: activity_pub

View file

@ -93,8 +93,8 @@ en:
title: Block lists
comments_btn_box:
text_pause: Pause
text_approve: Approve
text_reject: Reject
text_accept: Accept
text_reply: Reply
text_report: Report
instances_btn_box:

View file

@ -92,10 +92,9 @@ es:
block_lists:
title: Listas de bloqueo
comments_btn_box:
text_pause: Pausa
text_pause: Pausar
text_approve: Aceptar
text_reject: Rechazar
text_accept: Aceptar Publicación
text_reply: Responder
text_report: Reportar
instances_btn_box:
text_check: Moderar caso por caso

View file

@ -82,6 +82,14 @@ Rails.application.routes.draw do
patch :actor_moderations_action_on_several, to: 'actor_moderations#action_on_several'
resources :activity_pub, only: [] do
ActivityPub.events.each do |event|
patch event, to: "activity_pubs##{event}"
end
end
patch :activity_pubs_action_on_several, to: 'activity_pubs#action_on_several'
# Gestionar artículos según idioma
nested do
scope '/(:locale)', constraint: /[a-z]{2}(-[A-Z]{2})?/ do