Allow import/export of mutes list (#1541)
* Allow export of mutes list * Allow importing of mutes list * Refactor to use Settings::Exports::BaseController and DRY up exports code
This commit is contained in:
parent
08fce08217
commit
7f0a865b05
13 changed files with 86 additions and 19 deletions
23
app/controllers/settings/exports/base_controller.rb
Normal file
23
app/controllers/settings/exports/base_controller.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Settings
|
||||
module Exports
|
||||
class BaseController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
export_data = Export.new(export_accounts).to_csv
|
||||
|
||||
respond_to do |format|
|
||||
format.csv { send_data export_data, filename: export_filename }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def export_filename
|
||||
"#{controller_name}.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,15 +2,11 @@
|
|||
|
||||
module Settings
|
||||
module Exports
|
||||
class BlockedAccountsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
class BlockedAccountsController < BaseController
|
||||
private
|
||||
|
||||
def index
|
||||
export_data = Export.new(current_account.blocking).to_csv
|
||||
|
||||
respond_to do |format|
|
||||
format.csv { send_data export_data, filename: 'blocking.csv' }
|
||||
end
|
||||
def export_accounts
|
||||
current_account.blocking
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,15 +2,11 @@
|
|||
|
||||
module Settings
|
||||
module Exports
|
||||
class FollowingAccountsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
class FollowingAccountsController < BaseController
|
||||
private
|
||||
|
||||
def index
|
||||
export_data = Export.new(current_account.following).to_csv
|
||||
|
||||
respond_to do |format|
|
||||
format.csv { send_data export_data, filename: 'following.csv' }
|
||||
end
|
||||
def export_accounts
|
||||
current_account.following
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Settings
|
||||
module Exports
|
||||
class MutedAccountsController < BaseController
|
||||
private
|
||||
|
||||
def export_accounts
|
||||
current_account.muting
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,5 +9,6 @@ class Settings::ExportsController < ApplicationController
|
|||
@total_storage = current_account.media_attachments.sum(:file_file_size)
|
||||
@total_follows = current_account.following.count
|
||||
@total_blocks = current_account.blocking.count
|
||||
@total_mutes = current_account.muting.count
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue