mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-27 03:31:36 +01:00
acdeb162b8
An uncommon but somewhat difficult to digagnose issue is dealing with improperly-seeded databases. In such cases, instance-signed fetches will fail with a ActiveRecord::RecordNotFound error, usually caught and handled as generic 404, leading people to think the remote resource itself has not been found, while it's the local instance actor that does not exist. This commit changes the code so that failure to find the instance actor automatically creates a new one, so that improperly-seeded databases do not cause any issue.
22 lines
594 B
Ruby
22 lines
594 B
Ruby
# frozen_string_literal: true
|
|
|
|
class InstanceActorsController < ApplicationController
|
|
include AccountControllerConcern
|
|
|
|
skip_around_action :set_locale
|
|
|
|
def show
|
|
expires_in 10.minutes, public: true
|
|
render json: @account, content_type: 'application/activity+json', serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter, fields: restrict_fields_to
|
|
end
|
|
|
|
private
|
|
|
|
def set_account
|
|
@account = Account.representative
|
|
end
|
|
|
|
def restrict_fields_to
|
|
%i(id type preferred_username inbox outbox public_key endpoints url manually_approves_followers)
|
|
end
|
|
end
|