2019-07-02 03:10:25 -04: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-01 11:04:15 -04:00
|
|
|
user = params[:username].split("@")
|
2019-08-01 00:04:14 -04:00
|
|
|
if user[1]
|
2019-08-01 11:04:15 -04:00
|
|
|
user[1] = "#{user[1]}.#{params[:format]}"
|
2019-08-01 00:04:14 -04:00
|
|
|
@account = Account.find_remote!(user[0], user[1])
|
|
|
|
else
|
|
|
|
@account = Account.find_local!(user[0])
|
|
|
|
end
|
2019-07-02 03:10:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_account_suspension
|
|
|
|
gone if @account.suspended?
|
|
|
|
end
|
|
|
|
end
|