2019-07-02 08:10:25 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V1::AccountByUsernameController < Api::BaseController
|
|
|
|
before_action :set_account
|
|
|
|
before_action :check_account_suspension
|
|
|
|
|
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def show
|
|
|
|
render json: @account, serializer: REST::AccountSerializer
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_account
|
2019-08-02 00:19:31 +01:00
|
|
|
username, domain = params[:username].split("@")
|
|
|
|
if domain
|
|
|
|
@account = Account.find_remote!(username, domain)
|
2019-08-01 05:04:14 +01:00
|
|
|
else
|
2019-08-02 00:19:31 +01:00
|
|
|
@account = Account.find_local!(username)
|
2019-08-01 05:04:14 +01:00
|
|
|
end
|
2019-07-02 08:10:25 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_account_suspension
|
|
|
|
gone if @account.suspended?
|
|
|
|
end
|
|
|
|
end
|