Skip to content

Commit

Permalink
port tootsuite#11869 to monsterfork: Fix webfinger response not retur…
Browse files Browse the repository at this point in the history
…ning 410 when account is suspended
  • Loading branch information
Gargron authored and multiple creatures committed Feb 21, 2020
1 parent 085ae27 commit 1a9763b
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions app/controllers/well_known/webfinger_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ class WebfingerController < ActionController::Base
include RoutingHelper

before_action { response.headers['Vary'] = 'Accept' }
before_action :set_account
before_action :check_account_suspension

def show
@account = Account.find_local!(username_from_resource)
rescue_from ActiveRecord::RecordNotFound, ActionController::ParameterMissing, with: :not_found

def show
expires_in 3.days, public: true
render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json'
rescue ActiveRecord::RecordNotFound
head 404
end

private

def set_account
@account = Account.find_local!(username_from_resource)
end

def username_from_resource
resource_user = resource_param
username, domain = resource_user.split('@')
Expand All @@ -28,5 +32,17 @@ def username_from_resource
def resource_param
params.require(:resource)
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

0 comments on commit 1a9763b

Please sign in to comment.