gab-social/app/controllers/api/v1/account_by_username_controller.rb

25 lines
612 B
Ruby
Raw Normal View History

2019-07-02 08:10:25 +01:00
# frozen_string_literal: true
2021-01-12 05:17:19 +00:00
class Api::V1::AccountByUsernameController < EmptyController
2019-07-02 08:10:25 +01:00
before_action :set_account
before_action :check_account_suspension!
before_action :check_account_local!
2019-07-02 08:10:25 +01:00
def show
render json: @account, serializer: REST::AccountSerializer
end
def set_account
2019-11-18 01:54:18 +00:00
@account = Account.find_acct!(params[:username])
2019-07-02 08:10:25 +01:00
end
def check_account_suspension!
render json: { error: true }, status: 404 if @account.suspended?
2019-07-02 08:10:25 +01:00
end
2020-04-17 06:35:46 +01:00
# if not our domain don't display
def check_account_local!
render json: { error: true }, status: 404 unless @account.local?
2020-04-17 06:35:46 +01:00
end
2019-07-02 08:10:25 +01:00
end