|
|
@ -5,18 +5,22 @@ module WellKnown |
|
|
|
include RoutingHelper |
|
|
|
include RoutingHelper |
|
|
|
|
|
|
|
|
|
|
|
before_action { response.headers['Vary'] = 'Accept' } |
|
|
|
before_action { response.headers['Vary'] = 'Accept' } |
|
|
|
|
|
|
|
before_action :set_account |
|
|
|
|
|
|
|
before_action :check_account_suspension |
|
|
|
|
|
|
|
|
|
|
|
def show |
|
|
|
rescue_from ActiveRecord::RecordNotFound, ActionController::ParameterMissing, with: :not_found |
|
|
|
@account = Account.find_local!(username_from_resource) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show |
|
|
|
expires_in 3.days, public: true |
|
|
|
expires_in 3.days, public: true |
|
|
|
render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json' |
|
|
|
render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json' |
|
|
|
rescue ActiveRecord::RecordNotFound, ActionController::ParameterMissing |
|
|
|
|
|
|
|
head 404 |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_account |
|
|
|
|
|
|
|
@account = Account.find_local!(username_from_resource) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def username_from_resource |
|
|
|
def username_from_resource |
|
|
|
resource_user = resource_param |
|
|
|
resource_user = resource_param |
|
|
|
username, domain = resource_user.split('@') |
|
|
|
username, domain = resource_user.split('@') |
|
|
@ -28,5 +32,17 @@ module WellKnown |
|
|
|
def resource_param |
|
|
|
def resource_param |
|
|
|
params.require(:resource) |
|
|
|
params.require(:resource) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_account_suspension |
|
|
|
|
|
|
|
expires_in(3.minutes, public: true) && gone if @account.suspended? |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def not_found |
|
|
|
|
|
|
|
head 404 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gone |
|
|
|
|
|
|
|
head 410 |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|