File tree Expand file tree Collapse file tree
app/controllers/well_known Expand file tree Collapse file tree Original file line number Diff line number Diff 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
3248end
You can’t perform that action at this time.
0 commit comments