2024-03-01 18:04:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Envía un reporte directamente a la instancia remota
|
|
|
|
#
|
|
|
|
# @todo El panel debería ser su propia instancia y firmar sus propios
|
|
|
|
# mensajes.
|
|
|
|
# @todo Como la Social Inbox no soporta enviar actividades
|
|
|
|
# a destinataries que no sean seguidores, enviamos el reporte
|
|
|
|
# directamente a la instancia.
|
|
|
|
# @see {https://github.com/hyphacoop/social.distributed.press/issues/14}
|
|
|
|
class ActivityPub
|
|
|
|
class RemoteFlagJob < ApplicationJob
|
|
|
|
self.priority = 30
|
|
|
|
|
|
|
|
def perform(remote_flag:)
|
2024-03-05 19:00:47 +00:00
|
|
|
return if remote_flag.can_queue?
|
|
|
|
|
|
|
|
remote_flag.queue!
|
|
|
|
|
2024-03-05 17:18:06 +00:00
|
|
|
client = remote_flag.site.social_inbox.client_for(remote_flag.actor&.content['inbox'])
|
2024-03-01 18:04:07 +00:00
|
|
|
response = client.post(endpoint: '', body: remote_flag.content)
|
|
|
|
|
|
|
|
raise 'No se pudo enviar el reporte' unless response.ok?
|
2024-03-05 19:00:47 +00:00
|
|
|
|
|
|
|
remote_flag.send!
|
2024-03-01 18:04:07 +00:00
|
|
|
rescue Exception => e
|
|
|
|
ExceptionNotifier.notify_exception(e, data: { remote_flag: remote_flag.id, response: response.parsed_response })
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|