mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-24 23:21:48 +00:00
Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl
This commit is contained in:
commit
b136597e0c
3 changed files with 21 additions and 6 deletions
2
.env
2
.env
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue