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.

51 lines
976 B

  1. # frozen_string_literal: true
  2. class RemoteFollowController < ApplicationController
  3. layout 'modal'
  4. before_action :set_account
  5. before_action :set_pack
  6. before_action :gone, if: :suspended_account?
  7. before_action :set_body_classes
  8. def new
  9. @remote_follow = RemoteFollow.new(session_params)
  10. end
  11. def create
  12. @remote_follow = RemoteFollow.new(resource_params)
  13. if @remote_follow.valid?
  14. session[:remote_follow] = @remote_follow.acct
  15. redirect_to @remote_follow.subscribe_address_for(@account)
  16. else
  17. render :new
  18. end
  19. end
  20. private
  21. def resource_params
  22. params.require(:remote_follow).permit(:acct)
  23. end
  24. def session_params
  25. { acct: session[:remote_follow] }
  26. end
  27. def set_pack
  28. use_pack 'modal'
  29. end
  30. def set_account
  31. @account = Account.find_local!(params[:account_username])
  32. end
  33. def suspended_account?
  34. @account.suspended?
  35. end
  36. def set_body_classes
  37. @body_classes = 'modal-layout'
  38. end
  39. end