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.

41 lines
808 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. def new
  7. @remote_follow = RemoteFollow.new(session_params)
  8. end
  9. def create
  10. @remote_follow = RemoteFollow.new(resource_params)
  11. if @remote_follow.valid?
  12. session[:remote_follow] = @remote_follow.acct
  13. redirect_to @remote_follow.subscribe_address_for(@account)
  14. else
  15. render :new
  16. end
  17. end
  18. private
  19. def resource_params
  20. params.require(:remote_follow).permit(:acct)
  21. end
  22. def session_params
  23. { acct: session[:remote_follow] }
  24. end
  25. def set_account
  26. @account = Account.find_local!(params[:account_username])
  27. end
  28. def suspended_account?
  29. @account.suspended?
  30. end
  31. end