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-15 17:01:00 +00:00
|
|
|
before_action :authenticate_usuarie!
|
|
|
|
|
|
|
|
breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path
|
|
|
|
breadcrumb 'sites.index', :sites_path, match: :exact
|
|
|
|
|
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-18 15:55:27 +00:00
|
|
|
if actor_event == :report
|
|
|
|
remote_flag_params(actor_moderation).tap do |p|
|
|
|
|
actor_moderation.remote_flag_id = p[:remote_flag_attributes][:id]
|
|
|
|
actor_moderation.update(p)
|
|
|
|
end
|
|
|
|
end
|
2024-03-01 18:51:54 +00:00
|
|
|
|
2024-03-16 18:12:55 +00:00
|
|
|
message =
|
|
|
|
if actor_moderation.public_send(:"may_#{actor_event}?") && actor_moderation.public_send(:"#{actor_event}!")
|
|
|
|
:success
|
|
|
|
else
|
|
|
|
:error
|
|
|
|
end
|
2024-02-28 22:10:37 +00:00
|
|
|
|
2024-03-16 18:12:55 +00:00
|
|
|
flash[message] = I18n.t("actor_moderations.#{actor_event}.#{message}")
|
2024-03-08 18:07:32 +00:00
|
|
|
|
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
|
2024-03-16 14:32:16 +00:00
|
|
|
breadcrumb site.title, site_posts_path(site)
|
2024-03-15 17:01:00 +00:00
|
|
|
breadcrumb I18n.t('moderation_queue.index.title'), site_moderation_queue_path(site)
|
|
|
|
|
2024-02-29 18:54:53 +00:00
|
|
|
@remote_profile = actor_moderation.actor.content
|
2024-03-08 18:07:32 +00:00
|
|
|
@moderation_queue = rubanok_process(site.activity_pubs.where(actor_id: actor_moderation.actor_id),
|
|
|
|
with: ActivityPubProcessor)
|
2024-03-15 17:01:00 +00:00
|
|
|
|
|
|
|
breadcrumb @remote_profile['name'], ''
|
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
|
2024-03-12 16:57:31 +00:00
|
|
|
method = :"#{action}_all!"
|
2024-03-01 19:11:33 +00:00
|
|
|
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
|
2024-03-12 16:57:31 +00:00
|
|
|
if action == :report
|
|
|
|
actor_moderations.find_each do |actor_moderation|
|
|
|
|
next unless actor_moderation.public_send(may)
|
2024-03-04 20:14:46 +00:00
|
|
|
|
2024-03-12 16:57:31 +00:00
|
|
|
actor_moderation.update(actor_moderation_params(actor_moderation))
|
|
|
|
end
|
|
|
|
end
|
2024-03-08 18:07:32 +00:00
|
|
|
|
2024-03-16 22:05:12 +00:00
|
|
|
message = actor_moderations.public_send(method) ? :success : :error
|
2024-03-08 18:07:32 +00:00
|
|
|
|
2024-03-12 16:57:31 +00:00
|
|
|
flash[message] = I18n.t("actor_moderations.action_on_several.#{message}")
|
2024-03-01 19:11:33 +00:00
|
|
|
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
|