about summary refs log tree commit diff
path: root/app/controllers/well_known
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-09-17 14:58:02 +0200
committermultiple creatures <dev@multiple-creature.party>2020-02-20 23:03:38 -0600
commit1a9763b2bcdb892c8b5615043c2b3c7cdc5bc4e4 (patch)
tree7d1c92e3dc2a3f5c558f870b1ac4000c66e502e0 /app/controllers/well_known
parent085ae27088fb1b45a75e4131f7b6a9c3e6620216 (diff)
port tootsuite#11869 to monsterfork: Fix webfinger response not returning 410 when account is suspended
Diffstat (limited to 'app/controllers/well_known')
-rw-r--r--app/controllers/well_known/webfinger_controller.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/app/controllers/well_known/webfinger_controller.rb b/app/controllers/well_known/webfinger_controller.rb
index 50bace217..480e58f3f 100644
--- a/app/controllers/well_known/webfinger_controller.rb
+++ b/app/controllers/well_known/webfinger_controller.rb
@@ -5,18 +5,22 @@ module WellKnown
     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('@')
@@ -28,5 +32,17 @@ module WellKnown
     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