mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 00:36:21 +00:00
23 lines
537 B
Ruby
23 lines
537 B
Ruby
|
# 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
|