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.

46 lines
877 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. 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_pack
  27. use_pack 'modal'
  28. end
  29. def set_account
  30. @account = Account.find_local!(params[:account_username])
  31. end
  32. def suspended_account?
  33. @account.suspended?
  34. end
  35. end