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-12 20:30:47 +00:00
|
|
|
return if remote_flag.may_queue?
|
2024-03-05 19:00:47 +00:00
|
|
|
|
2024-03-15 19:52:42 +00:00
|
|
|
inbox = remote_flag.actor&.content&.[]('inbox')
|
|
|
|
|
|
|
|
raise 'Inbox is missing for actor' if inbox.blank?
|
|
|
|
|
2024-03-05 19:00:47 +00:00
|
|
|
remote_flag.queue!
|
|
|
|
|
2024-03-15 19:52:42 +00:00
|
|
|
uri = URI.parse(inbox)
|
|
|
|
client = remote_flag.main_site.social_inbox.client_for(uri.origin)
|
|
|
|
response = client.post(endpoint: uri.path, body: remote_flag.content)
|
2024-03-01 18:04:07 +00:00
|
|
|
|
|
|
|
raise 'No se pudo enviar el reporte' unless response.ok?
|
2024-03-05 19:00:47 +00:00
|
|
|
|
2024-03-06 17:12:04 +00:00
|
|
|
remote_flag.report!
|
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
|