mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 12:35:07 +01:00
8b9d0a0533
Fix #11453
33 lines
869 B
Ruby
33 lines
869 B
Ruby
# frozen_string_literal: true
|
|
|
|
module WellKnown
|
|
class WebfingerController < ActionController::Base
|
|
include RoutingHelper
|
|
|
|
before_action { response.headers['Vary'] = 'Accept' }
|
|
|
|
def show
|
|
@account = Account.find_local!(username_from_resource)
|
|
|
|
expires_in 3.days, public: true
|
|
render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json'
|
|
rescue ActiveRecord::RecordNotFound
|
|
head 404
|
|
end
|
|
|
|
private
|
|
|
|
def username_from_resource
|
|
resource_user = resource_param
|
|
username, domain = resource_user.split('@')
|
|
resource_user = "#{username}@#{Rails.configuration.x.local_domain}" if Rails.configuration.x.alternate_domains.include?(domain)
|
|
|
|
WebfingerResource.new(resource_user).username
|
|
end
|
|
|
|
def resource_param
|
|
params.require(:resource)
|
|
end
|
|
end
|
|
end
|