2024-02-26 15:27:56 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Actualiza la relación entre un sitio y una instancia
|
|
|
|
class InstanceModerationsController < ApplicationController
|
2024-02-26 20:37:34 +00:00
|
|
|
before_action :authorize_policy, except: %i[action_on_several]
|
2024-02-26 15:27:56 +00:00
|
|
|
|
|
|
|
def pause
|
|
|
|
instance_moderation.pause!
|
|
|
|
|
|
|
|
redirect_to site_moderation_queue_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def allow
|
|
|
|
instance_moderation.allow!
|
|
|
|
|
|
|
|
redirect_to site_moderation_queue_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def block
|
|
|
|
instance_moderation.block!
|
|
|
|
|
|
|
|
redirect_to site_moderation_queue_path
|
|
|
|
end
|
|
|
|
|
2024-02-26 20:37:34 +00:00
|
|
|
def action_on_several
|
|
|
|
instance_moderations = site.instance_moderations.where(id: params[:instance_moderation])
|
|
|
|
|
|
|
|
authorize instance_moderations
|
|
|
|
|
|
|
|
action = params[:instance_moderation_action].to_sym
|
|
|
|
method = :"#{action}!"
|
|
|
|
|
|
|
|
InstanceModeration.transaction do
|
|
|
|
instance_moderations.find_each do |instance_moderation|
|
|
|
|
events = instance_moderation.aasm.events.map(&:name)
|
|
|
|
|
|
|
|
next unless events.include? action
|
|
|
|
|
|
|
|
instance_moderation.public_send(method)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to site_moderation_queue_path
|
|
|
|
end
|
|
|
|
|
2024-02-26 15:27:56 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
# @return [InstanceModeration]
|
|
|
|
def instance_moderation
|
|
|
|
@instance_moderation ||= site.instance_moderations.find(params[:instance_moderation_id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_policy
|
|
|
|
authorize instance_moderation
|
|
|
|
end
|
|
|
|
end
|