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