5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 01:56:21 +00:00

feat: cambiar el estado de les actores desde el panel

This commit is contained in:
f 2024-02-28 19:10:37 -03:00
parent 0539eb8f22
commit 5370a542ff
No known key found for this signature in database
8 changed files with 58 additions and 15 deletions

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
# Gestiona la cola de moderación de actores
class ActorModerationsController < ApplicationController
ActorModeration.aasm.events.map(&:name).each do |actor_event|
define_method(actor_event) do
authorize actor_moderation
actor_moderation.public_send(:"#{actor_event}!") if actor_moderation.public_send(:"may_#{actor_event}?")
redirect_back fallback_location: site_moderation_queue_path(**(session[:moderation_queue_filters] || {}))
end
end
private
def actor_moderation
@actor_moderation ||= site.actor_moderations.find(params[:actor_moderation_id])
end
end

View file

@ -6,7 +6,7 @@ class ModerationQueueController < ApplicationController
def index def index
dummy_data dummy_data
session[:moderation_queue_filtered_by_state] = params[:state] session[:moderation_queue_filters] = params.permit(:state, :actor_state)
# @todo cambiar el estado por query # @todo cambiar el estado por query
@activity_pubs = site.activity_pubs @activity_pubs = site.activity_pubs

View file

@ -7,6 +7,10 @@ class ActorModeration < ApplicationRecord
belongs_to :site belongs_to :site
belongs_to :actor, class_name: 'ActivityPub::Actor' belongs_to :actor, class_name: 'ActivityPub::Actor'
def self.events
aasm.events.map(&:name)
end
aasm do aasm do
state :paused, initial: true state :paused, initial: true
state :allowed state :allowed
@ -37,7 +41,7 @@ class ActorModeration < ApplicationRecord
end end
end end
event :reported do event :report do
transitions from: %i[blocked], to: :reported transitions from: %i[blocked], to: :reported
end end
end end

View file

@ -0,0 +1,16 @@
# frozen_string_literal: true
# Solo les usuaries pueden moderar actores
ActorModerationPolicy = Struct.new(:usuarie, :actor_moderation) do
ActorModeration.events.each do |actor_event|
define_method(:"#{actor_event}?") do
actor_moderation.site.usuarie? usuarie
end
end
# En este paso tenemos varias cuentas por moderar pero todas son
# del mismo sitio.
def action_on_several?
actor_moderation.first.site.usuarie? usuarie
end
end

View file

@ -1,7 +1,9 @@
-# Componente Botonera de Moderación de Cuentas (Remote_profile) -# Componente Botonera de Moderación de Cuentas (Remote_profile)
- btn_class = 'btn-secondary' - btn_class = 'btn-secondary'
= render 'components/btn_base', text: t('.text_approve'), class: btn_class, href: '' - ActorModeration.events.each do |actor_event|
= render 'components/btn_base', text: t('.text_check'), class: btn_class, href: '' = render 'components/btn_base',
= render 'components/btn_base', text: t('.text_deny'), class: btn_class, href: '' text: t(".text_#{actor_event}"),
= render 'components/btn_base', text: t('.text_report'), class: btn_class, href: '' path: public_send(:"site_actor_moderation_#{actor_event}_path", actor_moderation_id: actor_moderation),
class: btn_class,
disabled: !actor_moderation.public_send(:"may_#{actor_event}?")

View file

@ -3,9 +3,10 @@
= render 'components/checkbox', id: profile['id'], name: 'actor[]', value: profile['id'], data: { target: 'select-all.input' } = render 'components/checkbox', id: profile['id'], name: 'actor[]', value: profile['id'], data: { target: 'select-all.input' }
.col-11 .col-11
%h4 %h4
%a{href: profile['id']}= profile['preferredUsername'] %a{href: profile['id']}= sanitize profile['name']
=profile['summary'].html_safe .mb-3
= sanitize profile['summary'].html_safe
-# Botones de Moderación -# Botones de Moderación
.d-flex.pb-4 .d-flex.pb-4
= render 'components/profiles_btn_box' = render 'components/profiles_btn_box', actor_moderation: actor_moderation

View file

@ -102,9 +102,9 @@ en:
text_allow: Allow everything text_allow: Allow everything
text_deny: Block instance text_deny: Block instance
profiles_btn_box: profiles_btn_box:
text_approve: Always approve text_pause: Always check
text_check: Always check text_allow: Always approve
text_deny: Block text_block: Block
text_report: Report text_report: Report
moderation_queue: moderation_queue:
everything: 'Select all' everything: 'Select all'

View file

@ -102,9 +102,9 @@ es:
text_allow: Permitir todo text_allow: Permitir todo
text_deny: Bloquear instancia text_deny: Bloquear instancia
profiles_btn_box: profiles_btn_box:
text_approve: Aprobar siempre text_pause: Revisar siempre
text_check: Revisar siempre text_allow: Aprobar siempre
text_deny: Bloquear text_block: Bloquear
text_report: Reportar text_report: Reportar
moderation_queue: moderation_queue:
everything: 'Seleccionar todo' everything: 'Seleccionar todo'