5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 05:36:21 +00:00

feat: enviar un reporte por actore

This commit is contained in:
f 2024-03-05 15:46:33 -03:00
parent 054dbc31e0
commit 30fd6c28ee
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View file

@ -28,6 +28,20 @@ class ActivityPubsController < ApplicationController
return unless ActivityPub.events.include? action
# Crear una sola remote flag por autore
if action == :report
message = remote_flag_params(activity_pubs.first).dig(:remote_flag_attributes, :message)
activity_pubs.distinct.pluck(:actor_id).each do |actor_id|
remote_flag = ActivityPub::RemoteFlag.find_or_initialize_by(actor_id: actor_id, site_id: site.id)
remote_flag.message = message
remote_flag.save
# XXX: Idealmente todas las ActivityPub que enviamos pueden
# cambiar de estado, pero chequeamos de todas formas.
remote_flag.activity_pubs << (activity_pubs.where(actor_id: actor_id).to_a.select { |a| a.public_send(may) })
end
end
ActivityPub.transaction do
activity_pubs.find_each do |activity_pub|
next unless activity_pub.public_send(may)

View file

@ -16,7 +16,7 @@ module ModerationConcern
end
def remote_flag_params(model)
{ remote_flag_attributes: { id: model.remote_flag_id, message: '' } }.tap do |p|
{ remote_flag_attributes: { id: model.remote_flag_id, message: ''.dup } }.tap do |p|
p[:remote_flag_attributes][:site_id] = model.site_id
p[:remote_flag_attributes][:actor_id] = model.actor_id