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.
 
 
 
 

38 regels
766 B

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