5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 03:36:22 +00:00
panel/app/models/activity_pub/instance.rb

41 lines
962 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# = Instance =
#
# Representa cada instancia del fediverso que interactúa con la Social
# Inbox.
2024-02-21 15:46:38 +00:00
class ActivityPub
class Instance < ApplicationRecord
include AASM
2024-02-21 15:46:38 +00:00
validates :aasm_state, presence: true, inclusion: { in: %w[paused allowed blocked] }
validates :hostname, uniqueness: true, hostname: { allow_numeric_hostname: true }
2024-02-21 15:46:38 +00:00
has_many :activity_pubs
has_many :actors
has_many :instance_moderations
# XXX: Mantenemos esto por si queremos bloquear una instancia a
# nivel general
2024-02-21 15:46:38 +00:00
aasm do
state :paused, initial: true
state :allowed
state :blocked
2024-02-27 15:32:09 +00:00
# Al pasar una instancia a bloqueo, quiere decir que todos los
# sitios adoptan esta lista
event :block do
transitions from: %i[paused allowed], to: :blocked
end
2024-02-21 15:46:38 +00:00
end
def list_name
"@*@#{hostname}"
end
def uri
@uri ||= "https://#{hostname}/"
end
end
end