2024-03-01 18:51:54 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub
|
|
|
|
class RemoteFlag < ApplicationRecord
|
2024-03-15 19:52:42 +00:00
|
|
|
IGNORED_EVENTS = [].freeze
|
|
|
|
IGNORED_STATES = [].freeze
|
2024-03-12 18:59:42 +00:00
|
|
|
|
2024-03-05 19:00:47 +00:00
|
|
|
include AASM
|
|
|
|
|
|
|
|
aasm do
|
|
|
|
state :waiting, initial: true
|
|
|
|
state :queued
|
|
|
|
state :sent
|
|
|
|
|
|
|
|
event :queue do
|
|
|
|
transitions from: :waiting, to: :queued
|
|
|
|
end
|
|
|
|
|
2024-03-06 17:12:04 +00:00
|
|
|
event :report do
|
2024-03-05 19:00:47 +00:00
|
|
|
transitions from: :queued, to: :sent
|
|
|
|
end
|
|
|
|
|
|
|
|
event :resend do
|
|
|
|
transitions from: :sent, to: :waiting
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-03-13 14:15:31 +00:00
|
|
|
# Definir eventos en masa
|
|
|
|
include AasmEventsConcern
|
|
|
|
|
2024-03-01 18:51:54 +00:00
|
|
|
belongs_to :actor
|
|
|
|
belongs_to :site
|
|
|
|
|
2024-03-05 17:18:06 +00:00
|
|
|
has_one :actor_moderation
|
|
|
|
has_many :activity_pubs
|
|
|
|
# XXX: source_type es obligatorio para el `through`
|
|
|
|
has_many :objects, through: :activity_pubs, source_type: 'ActivityPub::Object::Note'
|
|
|
|
|
2024-03-01 18:51:54 +00:00
|
|
|
# Genera la actividad a enviar
|
|
|
|
def content
|
|
|
|
{
|
|
|
|
'@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',
|
2024-03-15 19:52:42 +00:00
|
|
|
'actor' => main_site.social_inbox.actor_id,
|
2024-03-01 18:51:54 +00:00
|
|
|
'content' => message.to_s,
|
2024-03-15 19:52:42 +00:00
|
|
|
'object' => [actor.uri] + objects.pluck(:uri)
|
2024-03-01 18:51:54 +00:00
|
|
|
}
|
|
|
|
end
|
2024-03-15 19:52:42 +00:00
|
|
|
|
|
|
|
# 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
|
2024-03-01 18:51:54 +00:00
|
|
|
end
|
|
|
|
end
|