mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 00:06:21 +00:00
feat: cambiar el estado de les actores desde el panel
This commit is contained in:
parent
0539eb8f22
commit
5370a542ff
8 changed files with 58 additions and 15 deletions
20
app/controllers/actor_moderations_controller.rb
Normal file
20
app/controllers/actor_moderations_controller.rb
Normal 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
|
|
@ -6,7 +6,7 @@ class ModerationQueueController < ApplicationController
|
|||
def index
|
||||
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
|
||||
@activity_pubs = site.activity_pubs
|
||||
|
|
|
@ -7,6 +7,10 @@ class ActorModeration < ApplicationRecord
|
|||
belongs_to :site
|
||||
belongs_to :actor, class_name: 'ActivityPub::Actor'
|
||||
|
||||
def self.events
|
||||
aasm.events.map(&:name)
|
||||
end
|
||||
|
||||
aasm do
|
||||
state :paused, initial: true
|
||||
state :allowed
|
||||
|
@ -37,7 +41,7 @@ class ActorModeration < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
event :reported do
|
||||
event :report do
|
||||
transitions from: %i[blocked], to: :reported
|
||||
end
|
||||
end
|
||||
|
|
16
app/policies/actor_moderation_policy.rb
Normal file
16
app/policies/actor_moderation_policy.rb
Normal 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
|
|
@ -1,7 +1,9 @@
|
|||
-# Componente Botonera de Moderación de Cuentas (Remote_profile)
|
||||
|
||||
- btn_class = 'btn-secondary'
|
||||
= render 'components/btn_base', text: t('.text_approve'), class: btn_class, href: ''
|
||||
= render 'components/btn_base', text: t('.text_check'), class: btn_class, href: ''
|
||||
= render 'components/btn_base', text: t('.text_deny'), class: btn_class, href: ''
|
||||
= render 'components/btn_base', text: t('.text_report'), class: btn_class, href: ''
|
||||
- ActorModeration.events.each do |actor_event|
|
||||
= render 'components/btn_base',
|
||||
text: t(".text_#{actor_event}"),
|
||||
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}?")
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
= render 'components/checkbox', id: profile['id'], name: 'actor[]', value: profile['id'], data: { target: 'select-all.input' }
|
||||
.col-11
|
||||
%h4
|
||||
%a{href: profile['id']}= profile['preferredUsername']
|
||||
=profile['summary'].html_safe
|
||||
%a{href: profile['id']}= sanitize profile['name']
|
||||
.mb-3
|
||||
= sanitize profile['summary'].html_safe
|
||||
|
||||
-# Botones de Moderación
|
||||
.d-flex.pb-4
|
||||
= render 'components/profiles_btn_box'
|
||||
= render 'components/profiles_btn_box', actor_moderation: actor_moderation
|
||||
|
|
|
@ -102,9 +102,9 @@ en:
|
|||
text_allow: Allow everything
|
||||
text_deny: Block instance
|
||||
profiles_btn_box:
|
||||
text_approve: Always approve
|
||||
text_check: Always check
|
||||
text_deny: Block
|
||||
text_pause: Always check
|
||||
text_allow: Always approve
|
||||
text_block: Block
|
||||
text_report: Report
|
||||
moderation_queue:
|
||||
everything: 'Select all'
|
||||
|
|
|
@ -102,9 +102,9 @@ es:
|
|||
text_allow: Permitir todo
|
||||
text_deny: Bloquear instancia
|
||||
profiles_btn_box:
|
||||
text_approve: Aprobar siempre
|
||||
text_check: Revisar siempre
|
||||
text_deny: Bloquear
|
||||
text_pause: Revisar siempre
|
||||
text_allow: Aprobar siempre
|
||||
text_block: Bloquear
|
||||
text_report: Reportar
|
||||
moderation_queue:
|
||||
everything: 'Seleccionar todo'
|
||||
|
|
Loading…
Reference in a new issue