Skip to content

Commit 7c1722b

Browse files
Gargronhiyuki2578
authored andcommitted
Fix webfinger response not returning 410 when account is suspended (mastodon#11869)
1 parent 216a39b commit 7c1722b

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

app/controllers/well_known/webfinger_controller.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ class WebfingerController < ActionController::Base
55
include RoutingHelper
66

77
before_action { response.headers['Vary'] = 'Accept' }
8+
before_action :set_account
9+
before_action :check_account_suspension
810

9-
def show
10-
@account = Account.find_local!(username_from_resource)
11+
rescue_from ActiveRecord::RecordNotFound, ActionController::ParameterMissing, with: :not_found
1112

13+
def show
1214
expires_in 3.days, public: true
1315
render json: @account, serializer: WebfingerSerializer, content_type: 'application/jrd+json'
14-
rescue ActiveRecord::RecordNotFound, ActionController::ParameterMissing
15-
head 404
1616
end
1717

1818
private
1919

20+
def set_account
21+
@account = Account.find_local!(username_from_resource)
22+
end
23+
2024
def username_from_resource
2125
resource_user = resource_param
2226
username, domain = resource_user.split('@')
@@ -28,5 +32,17 @@ def username_from_resource
2832
def resource_param
2933
params.require(:resource)
3034
end
35+
36+
def check_account_suspension
37+
expires_in(3.minutes, public: true) && gone if @account.suspended?
38+
end
39+
40+
def not_found
41+
head 404
42+
end
43+
44+
def gone
45+
head 410
46+
end
3147
end
3248
end

0 commit comments

Comments
 (0)