1
0

remote_follow_controller.rb 816 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # frozen_string_literal: true
  2. class RemoteFollowController < ApplicationController
  3. include AccountOwnedConcern
  4. layout 'modal'
  5. before_action :set_body_classes
  6. skip_before_action :require_functional!
  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] || current_account&.username }
  25. end
  26. def set_body_classes
  27. @body_classes = 'modal-layout'
  28. @hide_header = true
  29. end
  30. end