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

View File

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