2024-03-04 16:49:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Gestiona acciones de moderación
|
|
|
|
class ActivityPubsController < ApplicationController
|
2024-03-04 17:47:20 +00:00
|
|
|
include ModerationConcern
|
|
|
|
|
2024-03-04 16:49:07 +00:00
|
|
|
ActivityPub.events.each do |event|
|
|
|
|
define_method(event) do
|
2024-03-04 17:47:20 +00:00
|
|
|
authorize activity_pub
|
|
|
|
|
2024-03-04 16:49:07 +00:00
|
|
|
activity_pub.public_send(:"#{event}!") if activity_pub.public_send(:"may_#{event}?")
|
|
|
|
|
2024-03-04 17:47:20 +00:00
|
|
|
redirect_to_moderation_queue!
|
2024-03-04 16:49:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def action_on_several
|
2024-03-04 18:13:01 +00:00
|
|
|
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}?"
|
|
|
|
|
2024-03-04 17:47:20 +00:00
|
|
|
redirect_to_moderation_queue!
|
2024-03-04 18:13:01 +00:00
|
|
|
|
|
|
|
return unless ActivityPub.events.include? action
|
|
|
|
|
|
|
|
ActivityPub.transaction do
|
|
|
|
activity_pubs.find_each do |activity_pub|
|
|
|
|
activity_pub.public_send(method) if activity_pub.public_send(may)
|
|
|
|
end
|
|
|
|
end
|
2024-03-04 16:49:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def activity_pub
|
|
|
|
@activity_pub ||= site.activity_pubs.find(params[:activity_pub_id])
|
|
|
|
end
|
|
|
|
end
|