5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 14:56:22 +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} # @see {https://www.w3.org/TR/activitypub/#client-to-server-interactions}
class ActivityPub < ApplicationRecord class ActivityPub < ApplicationRecord
include AASM include AASM
include AasmEventsConcern
IGNORED_EVENTS = %i[remove]
belongs_to :instance belongs_to :instance
belongs_to :site belongs_to :site

View file

@ -3,6 +3,9 @@
# Mantiene la relación entre Site y Actor # Mantiene la relación entre Site y Actor
class ActorModeration < ApplicationRecord class ActorModeration < ApplicationRecord
include AASM include AASM
include AasmEventsConcern
IGNORED_EVENTS = []
belongs_to :site belongs_to :site
belongs_to :remote_flag, class_name: 'ActivityPub::RemoteFlag' 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) self.update_all(aasm_state: 'paused', updated_at: Time.now)
end end
# Todos los eventos de la máquina de estados
#
# @return [Array<Symbol>]
def self.events
aasm.events.map(&:name)
end
aasm do aasm do
state :paused, initial: true state :paused, initial: true
state :allowed 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 -# Componente Botón general Moderación
- local_assigns[:method] ||= 'patch' - local_assigns[:method] ||= 'patch'
- local_assigns[:class] ||= 'btn-secondary'
- local_assigns[:class] = "btn #{local_assigns[:class]}" - local_assigns[:class] = "btn #{local_assigns[:class]}"
-# @todo path es obligatorio -# @todo path es obligatorio

View file

@ -1,8 +1,8 @@
-# Componente Botonera de Comentarios -# Componente Botonera de Comentarios
- btn_class = 'btn-secondary py-1 px-2' .d-flex.flex-row
= render 'components/btn_base', text: t('.text_pause'), class: btn_class, href: '' - ActivityPub.events.each do |event|
= render 'components/btn_base', text: t('.text_reject'), class: btn_class, href: '' = render 'components/btn_base',
= render 'components/btn_base', text: t('.text_accept'), class: btn_class, href: '' text: t(".text_#{event}"),
= render 'components/btn_base', text: t('.text_reply'), class: btn_class, href: '' path: public_send(:"site_activity_pub_#{event}_path", activity_pub_id: activity_pub),
= render 'components/btn_base', text: t('.text_report'), class: btn_class, href: '' 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'] - in_reply_to = text_plain comment['inReplyTo']
- summary = text_plain(comment['summary']) - summary = text_plain comment['summary']
.row.no-gutters .row.no-gutters
.col-1 .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 .col-11
.d-flex.flex-row.align-items-center.justify-content-between .d-flex.flex-row.align-items-center.justify-content-between
%h4.mb-0 %h4.mb-0
@ -25,3 +30,4 @@
= sanitize comment['content'] = sanitize comment['content']
- else - else
= sanitize comment['content'] = sanitize comment['content']
= render 'components/comments_btn_box', activity_pub: activity_pub

View file

@ -1,14 +1,14 @@
.row.no-gutters.pt-2 %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 .col-1.d-flex.align-items-center
= render 'components/select_all', id: 'select-all-comments' = 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 |activity_pub| - 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 %hr
= render 'comment', comment: activity_pub.object.content, profile: activity_pub.actor.content = render 'comment', comment: activity_pub.object.content, profile: activity_pub.actor.content, activity_pub: activity_pub
-# Botones moderación
.d-flex.justify-content-center
= render 'components/comments_btn_box', comment: activity_pub.object.content

View file

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

View file

@ -92,10 +92,9 @@ es:
block_lists: block_lists:
title: Listas de bloqueo title: Listas de bloqueo
comments_btn_box: comments_btn_box:
text_pause: Pausa text_pause: Pausar
text_approve: Aceptar
text_reject: Rechazar text_reject: Rechazar
text_accept: Aceptar Publicación
text_reply: Responder
text_report: Reportar text_report: Reportar
instances_btn_box: instances_btn_box:
text_check: Moderar caso por caso 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' 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 # Gestionar artículos según idioma
nested do nested do
scope '/(:locale)', constraint: /[a-z]{2}(-[A-Z]{2})?/ do scope '/(:locale)', constraint: /[a-z]{2}(-[A-Z]{2})?/ do