]> cat aescling's git repositories - mastodon.git/blob - app/controllers/settings/migrations_controller.rb
Set @body_classes to admin layout (#9081)
[mastodon.git] / app / controllers / settings / migrations_controller.rb
1 # frozen_string_literal: true
2
3 class Settings::MigrationsController < ApplicationController
4 layout 'admin'
5
6 before_action :authenticate_user!
7 before_action :set_body_classes
8
9 def show
10 @migration = Form::Migration.new(account: current_account.moved_to_account)
11 end
12
13 def update
14 @migration = Form::Migration.new(resource_params)
15
16 if @migration.valid? && migration_account_changed?
17 current_account.update!(moved_to_account: @migration.account)
18 ActivityPub::UpdateDistributionWorker.perform_async(current_account.id)
19 redirect_to settings_migration_path, notice: I18n.t('migrations.updated_msg')
20 else
21 render :show
22 end
23 end
24
25 private
26
27 def resource_params
28 params.require(:migration).permit(:acct)
29 end
30
31 def migration_account_changed?
32 current_account.moved_to_account_id != @migration.account&.id &&
33 current_account.id != @migration.account&.id
34 end
35
36 def set_body_classes
37 @body_classes = 'admin'
38 end
39 end
This page took 0.077397 seconds and 4 git commands to generate.