5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 00:36:21 +00:00
panel/app/jobs/activity_pub/instance_fetch_job.rb

23 lines
537 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class ActivityPub
# Obtiene o actualiza los datos de una instancia.
class InstanceFetchJob < ApplicationJob
def perform(site:, instance:)
%w[/api/v2/instance /api/v1/instance].each do |api|
uri = SocialInbox.generate_uri(instance.hostname) do |u|
u.path = api
end
response = site.social_inbox.dereferencer.get(uri: uri)
next unless response.ok?
instance.update(content: response.parsed_response)
break
end
end
end
end