5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-05-21 05:20:50 +00:00

fix: enviar el reporte firmado por el sitio #15605

pasaban dos cosas:

1. para firmar correctamente, el cliente necesita recibir el path
   completo por su parámetro `endpoint`

2. la petición tiene que ser hecha por le misme actore que hace el
   reporte, como estábamos firmando con el sitio, mastodon creía que era
   un relay y esperaba que se envíen firmas ld
This commit is contained in:
f 2024-03-15 16:52:42 -03:00
parent 6412fc108e
commit fcbff3e1c1
No known key found for this signature in database
3 changed files with 21 additions and 6 deletions

2
.env
View file

@ -39,3 +39,5 @@ GITLAB_PROJECT=
GITLAB_TOKEN=
PGVER=15
PGPID=/run/postgresql.pid
PANEL_ACTOR_MENTION=@sutty@sutty.nl
PANEL_ACTOR_SITE_ID=1

View file

@ -15,10 +15,15 @@ class ActivityPub
def perform(remote_flag:)
return if remote_flag.may_queue?
inbox = remote_flag.actor&.content&.[]('inbox')
raise 'Inbox is missing for actor' if inbox.blank?
remote_flag.queue!
client = remote_flag.site.social_inbox.client_for(remote_flag.actor&.content['inbox'])
response = client.post(endpoint: '', body: remote_flag.content)
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)
raise 'No se pudo enviar el reporte' unless response.ok?

View file

@ -2,8 +2,8 @@
class ActivityPub
class RemoteFlag < ApplicationRecord
IGNORED_EVENTS = []
IGNORED_STATES = []
IGNORED_EVENTS = [].freeze
IGNORED_STATES = [].freeze
include AASM
@ -42,10 +42,18 @@ class ActivityPub
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => Rails.application.routes.url_helpers.v1_activity_pub_remote_flag_url(self, host: site.social_inbox_hostname),
'type' => 'Flag',
'actor' => ENV.fetch('PANEL_ACTOR_ID') { "https://#{ENV['SUTTY']}/about.jsonld" },
'actor' => main_site.social_inbox.actor_id,
'content' => message.to_s,
'object' => [ actor.uri ] + objects.pluck(:uri)
'object' => [actor.uri] + objects.pluck(:uri)
}
end
# Este es el sitio principal que actúa como origen del reporte.
# Tiene que tener la Social Inbox habilitada al mismo tiempo.
#
# @return [Site]
def main_site
@main_site ||= Site.find(ENV.fetch('PANEL_ACTOR_SITE_ID') { 1 })
end
end
end