2024-02-20 17:44:52 +00:00
|
|
|
# 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-20 17:44:52 +00:00
|
|
|
|
2024-02-21 15:46:38 +00:00
|
|
|
validates :aasm_state, presence: true, inclusion: { in: %w[paused allowed blocked] }
|
2024-03-22 15:38:54 +00:00
|
|
|
validates :hostname, uniqueness: true, hostname: { allow_numeric_hostname: true }
|
2024-02-20 17:44:52 +00:00
|
|
|
|
2024-02-21 15:46:38 +00:00
|
|
|
has_many :activity_pubs
|
|
|
|
has_many :actors
|
2024-02-26 15:27:56 +00:00
|
|
|
has_many :instance_moderations
|
2024-02-20 17:44:52 +00:00
|
|
|
|
2024-02-26 19:12:56 +00:00
|
|
|
# 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
|
2024-02-24 16:04:52 +00:00
|
|
|
|
2024-02-26 19:12:56 +00:00
|
|
|
def list_name
|
|
|
|
"@*@#{hostname}"
|
|
|
|
end
|
|
|
|
|
2024-02-24 16:04:52 +00:00
|
|
|
def uri
|
|
|
|
@uri ||= "https://#{hostname}/"
|
|
|
|
end
|
2024-02-20 17:44:52 +00:00
|
|
|
end
|
|
|
|
end
|