Merge commit 'f877aa9d70d0d600961989b8e97c0e0ce3ac1db6' into glitch-soc/merge-upstream
Conflicts: - `.github/dependabot.yml`: Upstream made changes, but we had removed it. Discarded upstream changes. - `.rubocop_todo.yml`: Upstream regenerated the file, we had some glitch-soc-specific ignores. - `app/models/account_statuses_filter.rb`: Minor upstream code style change where glitch-soc had slightly different code due to handling of local-only posts. Updated to match upstream's code style. - `app/models/status.rb`: Upstream moved ActiveRecord callback definitions, glitch-soc had an extra one. Moved the definitions as upstream did. - `app/services/backup_service.rb`: Upstream rewrote a lot of the backup service, glitch-soc had changes because of exporting local-only posts. Took upstream changes and added back code to deal with local-only posts. - `config/routes.rb`: Upstream split the file into different files, while glitch-soc had a few extra routes. Extra routes added to `config/routes/settings.rb`, `config/routes/api.rb` and `config/routes/admin.rb` - `db/schema.rb`: Upstream has new migrations, while glitch-soc had an extra migration. Updated the expected serial number to match upstream's. - `lib/mastodon/version.rb`: Upstream added support to set version tags from environment variables, while glitch-soc has an extra `+glitch` tag. Changed the code to support upstream's feature but prepending a `+glitch`. - `spec/lib/activitypub/activity/create_spec.rb`: Minor code style change upstream, while glitch-soc has extra tests due to `directMessage` handling. Applied upstream's changes while keeping glitch-soc's extra tests. - `spec/models/concerns/account_interactions_spec.rb`: Minor code style change upstream, while glitch-soc has extra tests. Applied upstream's changes while keeping glitch-soc's extra tests.
This commit is contained in:
		@@ -15,7 +15,7 @@ class Settings::ExportsController < Settings::BaseController
 | 
			
		||||
  def create
 | 
			
		||||
    backup = nil
 | 
			
		||||
 | 
			
		||||
    with_lock("backup:#{current_user.id}") do
 | 
			
		||||
    with_redis_lock("backup:#{current_user.id}") do
 | 
			
		||||
      authorize :backup, :create?
 | 
			
		||||
      backup = current_user.backups.create!
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,31 +1,97 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class Settings::ImportsController < Settings::BaseController
 | 
			
		||||
  before_action :set_account
 | 
			
		||||
require 'csv'
 | 
			
		||||
 | 
			
		||||
  def show
 | 
			
		||||
    @import = Import.new
 | 
			
		||||
class Settings::ImportsController < Settings::BaseController
 | 
			
		||||
  before_action :set_bulk_import, only: [:show, :confirm, :destroy]
 | 
			
		||||
  before_action :set_recent_imports, only: [:index]
 | 
			
		||||
 | 
			
		||||
  TYPE_TO_FILENAME_MAP = {
 | 
			
		||||
    following: 'following_accounts_failures.csv',
 | 
			
		||||
    blocking: 'blocked_accounts_failures.csv',
 | 
			
		||||
    muting: 'muted_accounts_failures.csv',
 | 
			
		||||
    domain_blocking: 'blocked_domains_failures.csv',
 | 
			
		||||
    bookmarks: 'bookmarks_failures.csv',
 | 
			
		||||
  }.freeze
 | 
			
		||||
 | 
			
		||||
  TYPE_TO_HEADERS_MAP = {
 | 
			
		||||
    following: ['Account address', 'Show boosts', 'Notify on new posts', 'Languages'],
 | 
			
		||||
    blocking: false,
 | 
			
		||||
    muting: ['Account address', 'Hide notifications'],
 | 
			
		||||
    domain_blocking: false,
 | 
			
		||||
    bookmarks: false,
 | 
			
		||||
  }.freeze
 | 
			
		||||
 | 
			
		||||
  def index
 | 
			
		||||
    @import = Form::Import.new(current_account: current_account)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def show; end
 | 
			
		||||
 | 
			
		||||
  def failures
 | 
			
		||||
    @bulk_import = current_account.bulk_imports.where(state: :finished).find(params[:id])
 | 
			
		||||
 | 
			
		||||
    respond_to do |format|
 | 
			
		||||
      format.csv do
 | 
			
		||||
        filename = TYPE_TO_FILENAME_MAP[@bulk_import.type.to_sym]
 | 
			
		||||
        headers = TYPE_TO_HEADERS_MAP[@bulk_import.type.to_sym]
 | 
			
		||||
 | 
			
		||||
        export_data = CSV.generate(headers: headers, write_headers: true) do |csv|
 | 
			
		||||
          @bulk_import.rows.find_each do |row|
 | 
			
		||||
            case @bulk_import.type.to_sym
 | 
			
		||||
            when :following
 | 
			
		||||
              csv << [row.data['acct'], row.data.fetch('show_reblogs', true), row.data.fetch('notify', false), row.data['languages']&.join(', ')]
 | 
			
		||||
            when :blocking
 | 
			
		||||
              csv << [row.data['acct']]
 | 
			
		||||
            when :muting
 | 
			
		||||
              csv << [row.data['acct'], row.data.fetch('hide_notifications', true)]
 | 
			
		||||
            when :domain_blocking
 | 
			
		||||
              csv << [row.data['domain']]
 | 
			
		||||
            when :bookmarks
 | 
			
		||||
              csv << [row.data['uri']]
 | 
			
		||||
            end
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        send_data export_data, filename: filename
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def confirm
 | 
			
		||||
    @bulk_import.update!(state: :scheduled)
 | 
			
		||||
    BulkImportWorker.perform_async(@bulk_import.id)
 | 
			
		||||
    redirect_to settings_imports_path, notice: I18n.t('imports.success')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def create
 | 
			
		||||
    @import = Import.new(import_params)
 | 
			
		||||
    @import.account = @account
 | 
			
		||||
    @import = Form::Import.new(import_params.merge(current_account: current_account))
 | 
			
		||||
 | 
			
		||||
    if @import.save
 | 
			
		||||
      ImportWorker.perform_async(@import.id)
 | 
			
		||||
      redirect_to settings_import_path, notice: I18n.t('imports.success')
 | 
			
		||||
      redirect_to settings_import_path(@import.bulk_import.id)
 | 
			
		||||
    else
 | 
			
		||||
      render :show
 | 
			
		||||
      # We need to set recent imports as we are displaying the index again
 | 
			
		||||
      set_recent_imports
 | 
			
		||||
      render :index
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def destroy
 | 
			
		||||
    @bulk_import.destroy!
 | 
			
		||||
    redirect_to settings_imports_path
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def set_account
 | 
			
		||||
    @account = current_user.account
 | 
			
		||||
  def import_params
 | 
			
		||||
    params.require(:form_import).permit(:data, :type, :mode)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def import_params
 | 
			
		||||
    params.require(:import).permit(:data, :type, :mode)
 | 
			
		||||
  def set_bulk_import
 | 
			
		||||
    @bulk_import = current_account.bulk_imports.where(state: :unconfirmed).find(params[:id])
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def set_recent_imports
 | 
			
		||||
    @recent_imports = current_account.bulk_imports.reorder(id: :desc).limit(10)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class Settings::Preferences::AppearanceController < Settings::PreferencesController
 | 
			
		||||
class Settings::Preferences::AppearanceController < Settings::Preferences::BaseController
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def after_update_redirect_path
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class Settings::PreferencesController < Settings::BaseController
 | 
			
		||||
class Settings::Preferences::BaseController < Settings::BaseController
 | 
			
		||||
  def show; end
 | 
			
		||||
 | 
			
		||||
  def update
 | 
			
		||||
@@ -15,7 +15,7 @@ class Settings::PreferencesController < Settings::BaseController
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def after_update_redirect_path
 | 
			
		||||
    settings_preferences_path
 | 
			
		||||
    raise 'Override in controller'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def user_params
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class Settings::Preferences::NotificationsController < Settings::PreferencesController
 | 
			
		||||
class Settings::Preferences::NotificationsController < Settings::Preferences::BaseController
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def after_update_redirect_path
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class Settings::Preferences::OtherController < Settings::PreferencesController
 | 
			
		||||
class Settings::Preferences::OtherController < Settings::Preferences::BaseController
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def after_update_redirect_path
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user