mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 11:16:22 +00:00
feat: enviar un reporte por actore
This commit is contained in:
parent
054dbc31e0
commit
30fd6c28ee
2 changed files with 15 additions and 1 deletions
|
@ -28,6 +28,20 @@ class ActivityPubsController < ApplicationController
|
||||||
|
|
||||||
return unless ActivityPub.events.include? action
|
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
|
ActivityPub.transaction do
|
||||||
activity_pubs.find_each do |activity_pub|
|
activity_pubs.find_each do |activity_pub|
|
||||||
next unless activity_pub.public_send(may)
|
next unless activity_pub.public_send(may)
|
||||||
|
|
|
@ -16,7 +16,7 @@ module ModerationConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote_flag_params(model)
|
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][:site_id] = model.site_id
|
||||||
p[:remote_flag_attributes][:actor_id] = model.actor_id
|
p[:remote_flag_attributes][:actor_id] = model.actor_id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue