1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
mastodon/app/controllers/well_known/webfinger_controller.rb
Eugen Rochko 42bcbd36b7 Remove rabl dependency (#5894)
* Remove rabl dependency

* Replicate old Oj configuration
2017-12-06 15:04:49 +09:00

40 lines
963 B
Ruby

# frozen_string_literal: true
module WellKnown
class WebfingerController < ApplicationController
include RoutingHelper
def show
@account = Account.find_local!(username_from_resource)
respond_to do |format|
format.any(:json, :html) do
render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json'
end
format.xml do
render content_type: 'application/xrd+xml'
end
end
rescue ActiveRecord::RecordNotFound
head 404
end
private
def username_from_resource
resource_user = resource_param
username, domain = resource_user.split('@')
if Rails.configuration.x.alternate_domains.include?(domain)
resource_user = "#{username}@#{Rails.configuration.x.local_domain}"
end
WebfingerResource.new(resource_user).username
end
def resource_param
params.require(:resource)
end
end
end