mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 12:56:23 +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:
parent
6412fc108e
commit
fcbff3e1c1
3 changed files with 21 additions and 6 deletions
2
.env
2
.env
|
@ -39,3 +39,5 @@ GITLAB_PROJECT=
|
||||||
GITLAB_TOKEN=
|
GITLAB_TOKEN=
|
||||||
PGVER=15
|
PGVER=15
|
||||||
PGPID=/run/postgresql.pid
|
PGPID=/run/postgresql.pid
|
||||||
|
PANEL_ACTOR_MENTION=@sutty@sutty.nl
|
||||||
|
PANEL_ACTOR_SITE_ID=1
|
||||||
|
|
|
@ -15,10 +15,15 @@ class ActivityPub
|
||||||
def perform(remote_flag:)
|
def perform(remote_flag:)
|
||||||
return if remote_flag.may_queue?
|
return if remote_flag.may_queue?
|
||||||
|
|
||||||
|
inbox = remote_flag.actor&.content&.[]('inbox')
|
||||||
|
|
||||||
|
raise 'Inbox is missing for actor' if inbox.blank?
|
||||||
|
|
||||||
remote_flag.queue!
|
remote_flag.queue!
|
||||||
|
|
||||||
client = remote_flag.site.social_inbox.client_for(remote_flag.actor&.content['inbox'])
|
uri = URI.parse(inbox)
|
||||||
response = client.post(endpoint: '', body: remote_flag.content)
|
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?
|
raise 'No se pudo enviar el reporte' unless response.ok?
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
class ActivityPub
|
class ActivityPub
|
||||||
class RemoteFlag < ApplicationRecord
|
class RemoteFlag < ApplicationRecord
|
||||||
IGNORED_EVENTS = []
|
IGNORED_EVENTS = [].freeze
|
||||||
IGNORED_STATES = []
|
IGNORED_STATES = [].freeze
|
||||||
|
|
||||||
include AASM
|
include AASM
|
||||||
|
|
||||||
|
@ -42,10 +42,18 @@ class ActivityPub
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@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),
|
'id' => Rails.application.routes.url_helpers.v1_activity_pub_remote_flag_url(self, host: site.social_inbox_hostname),
|
||||||
'type' => 'Flag',
|
'type' => 'Flag',
|
||||||
'actor' => ENV.fetch('PANEL_ACTOR_ID') { "https://#{ENV['SUTTY']}/about.jsonld" },
|
'actor' => main_site.social_inbox.actor_id,
|
||||||
'content' => message.to_s,
|
'content' => message.to_s,
|
||||||
'object' => [ actor.uri ] + objects.pluck(:uri)
|
'object' => [actor.uri] + objects.pluck(:uri)
|
||||||
}
|
}
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue