Updated AccountByUsernameController to return error 404 if suspended

• Updated:
- AccountByUsernameController to return error 404 if suspended
This commit is contained in:
mgabdev 2021-01-12 00:51:03 -05:00
parent 5e6211a4f4
commit e689409a72
2 changed files with 6 additions and 10 deletions

View File

@ -2,8 +2,8 @@
class Api::V1::AccountByUsernameController < EmptyController
before_action :set_account
before_action :check_account_suspension
before_action :check_account_local
before_action :check_account_suspension!
before_action :check_account_local!
def show
render json: @account, serializer: REST::AccountSerializer
@ -13,12 +13,12 @@ class Api::V1::AccountByUsernameController < EmptyController
@account = Account.find_acct!(params[:username])
end
def check_account_suspension
gone if @account.suspended?
def check_account_suspension!
render json: { error: true }, status: 404 if @account.suspended?
end
# if not our domain don't display
def check_account_local
gone unless @account.local?
def check_account_local!
render json: { error: true }, status: 404 unless @account.local?
end
end

View File

@ -55,10 +55,6 @@ class EmptyController < ActionController::Base
nil
end
def gone
respond_with_error(410)
end
def cache_collection(raw, klass)
return raw unless klass.respond_to?(:with_includes)