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.

47 lines
932 B

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