remote_follow_controller.rb 744 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # frozen_string_literal: true
  2. class RemoteFollowController < ApplicationController
  3. include AccountOwnedConcern
  4. layout 'modal'
  5. before_action :set_body_classes
  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_body_classes
  26. @body_classes = 'modal-layout'
  27. @hide_header = true
  28. end
  29. end