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.

53 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. class RemoteInteractionController < ApplicationController
  3. include Authorization
  4. layout 'modal'
  5. before_action :set_status
  6. before_action :set_body_classes
  7. before_action :set_pack
  8. def new
  9. @remote_follow = RemoteFollow.new(session_params)
  10. end
  11. def create
  12. @remote_follow = RemoteFollow.new(resource_params)
  13. if @remote_follow.valid?
  14. session[:remote_follow] = @remote_follow.acct
  15. redirect_to @remote_follow.interact_address_for(@status)
  16. else
  17. render :new
  18. end
  19. end
  20. private
  21. def resource_params
  22. params.require(:remote_follow).permit(:acct)
  23. end
  24. def session_params
  25. { acct: session[:remote_follow] }
  26. end
  27. def set_status
  28. @status = Status.find(params[:id])
  29. authorize @status, :show?
  30. rescue Mastodon::NotPermittedError
  31. # Reraise in order to get a 404
  32. raise ActiveRecord::RecordNotFound
  33. end
  34. def set_body_classes
  35. @body_classes = 'modal-layout'
  36. @hide_header = true
  37. end
  38. def set_pack
  39. use_pack 'modal'
  40. end
  41. end