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.

48 lines
974 B

  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. 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.interact_address_for(@status)
  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_status
  27. @status = Status.find(params[:id])
  28. authorize @status, :show?
  29. rescue Mastodon::NotPermittedError
  30. # Reraise in order to get a 404
  31. raise ActiveRecord::RecordNotFound
  32. end
  33. def set_body_classes
  34. @body_classes = 'modal-layout'
  35. @hide_header = true
  36. end
  37. end