5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 23:56:22 +00:00
panel/app/models/activity_pub/remote_flag.rb

47 lines
1.2 KiB
Ruby
Raw Normal View History

2024-03-01 18:51:54 +00:00
# frozen_string_literal: true
class ActivityPub
class RemoteFlag < ApplicationRecord
include AASM
include AasmEventsConcern
aasm do
state :waiting, initial: true
state :queued
state :sent
event :queue do
transitions from: :waiting, to: :queued
end
event :send do
transitions from: :queued, to: :sent
end
event :resend do
transitions from: :sent, to: :waiting
end
end
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',
'actor' => ENV.fetch('PANEL_ACTOR_ID') { "https://#{ENV['SUTTY']}/about.jsonld" },
'content' => message.to_s,
2024-03-05 17:18:06 +00:00
'object' => [ actor.uri ] + objects.pluck(:uri)
2024-03-01 18:51:54 +00:00
}
end
end
end