1
0

statuses_cleanup_controller.rb 917 B

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. class StatusesCleanupController < ApplicationController
  3. layout 'admin'
  4. before_action :authenticate_user!
  5. before_action :set_policy
  6. before_action :set_body_classes
  7. def show; end
  8. def update
  9. if @policy.update(resource_params)
  10. redirect_to statuses_cleanup_path, notice: I18n.t('generic.changes_saved_msg')
  11. else
  12. render action: :show
  13. end
  14. rescue ActionController::ParameterMissing
  15. # Do nothing
  16. end
  17. private
  18. def set_policy
  19. @policy = current_account.statuses_cleanup_policy || current_account.build_statuses_cleanup_policy(enabled: false)
  20. end
  21. def resource_params
  22. params.require(:account_statuses_cleanup_policy).permit(:enabled, :min_status_age, :keep_direct, :keep_pinned, :keep_polls, :keep_media, :keep_self_fav, :keep_self_bookmark, :min_favs, :min_reblogs)
  23. end
  24. def set_body_classes
  25. @body_classes = 'admin'
  26. end
  27. end