# frozen_string_literal: true # Gestiona acciones de moderaciĆ³n class ActivityPubsController < ApplicationController include ModerationConcern ActivityPub.events.each do |event| define_method(event) do authorize activity_pub activity_pub.update(remote_flag_params(activity_pub)) if event == :report activity_pub.public_send(:"#{event}!") if activity_pub.public_send(:"may_#{event}?") redirect_to_moderation_queue! end end def action_on_several activity_pubs = site.activity_pubs.where(id: params[:activity_pub]) authorize activity_pubs action = params[:activity_pub_action].to_sym method = :"#{action}!" may = :"may_#{action}?" redirect_to_moderation_queue! return unless ActivityPub.events.include? action ActivityPub.transaction do activity_pubs.find_each do |activity_pub| next unless activity_pub.public_send(may) activity_pub.public_send(method) end end end private def activity_pub @activity_pub ||= site.activity_pubs.find(params[:activity_pub_id]) end end