The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
929 B

  1. # frozen_string_literal: true
  2. class Settings::ExportsController < Settings::BaseController
  3. include Authorization
  4. layout 'admin'
  5. before_action :authenticate_user!
  6. before_action :require_not_suspended!
  7. skip_before_action :require_functional!
  8. def show
  9. @export = Export.new(current_account)
  10. @backups = current_user.backups
  11. end
  12. def create
  13. raise Mastodon::NotPermittedError unless user_signed_in?
  14. backup = nil
  15. RedisLock.acquire(lock_options) do |lock|
  16. if lock.acquired?
  17. authorize :backup, :create?
  18. backup = current_user.backups.create!
  19. else
  20. raise Mastodon::RaceConditionError
  21. end
  22. end
  23. BackupWorker.perform_async(backup.id)
  24. redirect_to settings_export_path
  25. end
  26. def lock_options
  27. { redis: Redis.current, key: "backup:#{current_user.id}" }
  28. end
  29. def require_not_suspended!
  30. forbidden if current_account.suspended?
  31. end
  32. end