2019-09-19 18:58:19 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Settings::AliasesController < Settings::BaseController
|
2020-09-11 18:56:35 +00:00
|
|
|
skip_before_action :require_functional!
|
2019-09-19 18:58:19 +00:00
|
|
|
|
2020-09-11 18:56:35 +00:00
|
|
|
before_action :require_not_suspended!
|
2019-09-19 18:58:19 +00:00
|
|
|
before_action :set_aliases, except: :destroy
|
|
|
|
before_action :set_alias, only: :destroy
|
|
|
|
|
|
|
|
def index
|
|
|
|
@alias = current_account.aliases.build
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@alias = current_account.aliases.build(resource_params)
|
|
|
|
|
|
|
|
if @alias.save
|
2019-09-21 07:11:21 +00:00
|
|
|
ActivityPub::UpdateDistributionWorker.perform_async(current_account.id)
|
2019-09-19 18:58:19 +00:00
|
|
|
redirect_to settings_aliases_path, notice: I18n.t('aliases.created_msg')
|
|
|
|
else
|
2019-09-21 00:59:37 +00:00
|
|
|
render :index
|
2019-09-19 18:58:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@alias.destroy!
|
|
|
|
redirect_to settings_aliases_path, notice: I18n.t('aliases.deleted_msg')
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def resource_params
|
|
|
|
params.require(:account_alias).permit(:acct)
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_alias
|
|
|
|
@alias = current_account.aliases.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_aliases
|
|
|
|
@aliases = current_account.aliases.order(id: :desc).reject(&:new_record?)
|
|
|
|
end
|
|
|
|
end
|