5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:06:22 +00:00
panel/app/controllers/instance_moderations_controller.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
# Actualiza la relación entre un sitio y una instancia
class InstanceModerationsController < ApplicationController
2024-03-04 17:47:20 +00:00
include ModerationConcern
2024-03-04 17:47:20 +00:00
InstanceModeration.events.each do |event|
define_method(event) do
authorize instance_moderation
2024-03-04 17:47:20 +00:00
instance_moderation.public_send(:"#{event}!") if instance_moderation.public_send(:"may_#{event}?")
2024-03-04 17:47:20 +00:00
redirect_to_moderation_queue!
end
end
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}!"
may = :"may_#{action}?"
2024-03-04 17:47:20 +00:00
redirect_to_moderation_queue!
return unless InstanceModeration.events.include? action
InstanceModeration.transaction do
instance_moderations.find_each do |instance_moderation|
instance_moderation.public_send(method) if instance_moderation.public_send(may)
end
end
end
private
# @return [InstanceModeration]
def instance_moderation
@instance_moderation ||= site.instance_moderations.find(params[:instance_moderation_id])
end
end