2024-02-28 22:10:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Gestiona la cola de moderación de actores
|
|
|
|
class ActorModerationsController < ApplicationController
|
2024-03-04 17:47:20 +00:00
|
|
|
include ModerationConcern
|
2024-03-05 19:24:16 +00:00
|
|
|
include ModerationFiltersConcern
|
2024-03-04 17:47:20 +00:00
|
|
|
|
2024-03-01 18:51:54 +00:00
|
|
|
ActorModeration.events.each do |actor_event|
|
2024-02-28 22:10:37 +00:00
|
|
|
define_method(actor_event) do
|
|
|
|
authorize actor_moderation
|
|
|
|
|
2024-03-01 18:51:54 +00:00
|
|
|
# Crea una RemoteFlag si se envían los parámetros adecuados
|
2024-03-05 17:18:06 +00:00
|
|
|
actor_moderation.update(remote_flag_params(actor_moderation)) if actor_event == :report
|
2024-03-01 18:51:54 +00:00
|
|
|
|
2024-02-28 22:10:37 +00:00
|
|
|
actor_moderation.public_send(:"#{actor_event}!") if actor_moderation.public_send(:"may_#{actor_event}?")
|
|
|
|
|
2024-03-04 17:47:20 +00:00
|
|
|
redirect_to_moderation_queue!
|
2024-02-28 22:10:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-02-29 18:54:53 +00:00
|
|
|
# Ver el perfil remoto
|
|
|
|
def show
|
|
|
|
@remote_profile = actor_moderation.actor.content
|
2024-03-05 19:24:16 +00:00
|
|
|
@moderation_queue = rubanok_process(site.activity_pubs.where(actor_id: actor_moderation.actor_id), with: ActivityPubProcessor)
|
2024-02-29 18:54:53 +00:00
|
|
|
end
|
|
|
|
|
2024-03-01 19:11:33 +00:00
|
|
|
def action_on_several
|
|
|
|
actor_moderations = site.actor_moderations.where(id: params[:actor_moderation])
|
|
|
|
|
|
|
|
authorize actor_moderations
|
|
|
|
|
|
|
|
action = params[:actor_moderation_action].to_sym
|
|
|
|
method = :"#{action}!"
|
|
|
|
may = :"may_#{action}?"
|
|
|
|
|
2024-03-04 17:47:20 +00:00
|
|
|
redirect_to_moderation_queue!
|
|
|
|
|
2024-03-01 19:11:33 +00:00
|
|
|
return unless ActorModeration.events.include? action
|
|
|
|
|
|
|
|
ActorModeration.transaction do
|
|
|
|
actor_moderations.find_each do |actor_moderation|
|
2024-03-04 20:14:46 +00:00
|
|
|
next unless actor_moderation.public_send(may)
|
|
|
|
|
|
|
|
actor_moderation.update(actor_moderation_params(actor_moderation)) if action == :report
|
|
|
|
|
|
|
|
actor_moderation.public_send(method)
|
2024-03-01 19:11:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-02-28 22:10:37 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def actor_moderation
|
2024-02-29 18:54:53 +00:00
|
|
|
@actor_moderation ||= site.actor_moderations.find(params[:actor_moderation_id] || params[:id])
|
2024-02-28 22:10:37 +00:00
|
|
|
end
|
|
|
|
end
|