The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

56 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. class RemoteInteractionController < ApplicationController
  3. include Authorization
  4. layout 'modal'
  5. before_action :authenticate_user!, if: :whitelist_mode?
  6. before_action :set_interaction_type
  7. before_action :set_status
  8. before_action :set_body_classes
  9. skip_before_action :require_functional!
  10. def new
  11. @remote_follow = RemoteFollow.new(session_params)
  12. end
  13. def create
  14. @remote_follow = RemoteFollow.new(resource_params)
  15. if @remote_follow.valid?
  16. session[:remote_follow] = @remote_follow.acct
  17. redirect_to @remote_follow.interact_address_for(@status)
  18. else
  19. render :new
  20. end
  21. end
  22. private
  23. def resource_params
  24. params.require(:remote_follow).permit(:acct)
  25. end
  26. def session_params
  27. { acct: session[:remote_follow] || current_account&.username }
  28. end
  29. def set_status
  30. @status = Status.find(params[:id])
  31. authorize @status, :show?
  32. rescue Mastodon::NotPermittedError
  33. raise ActiveRecord::RecordNotFound
  34. end
  35. def set_body_classes
  36. @body_classes = 'modal-layout'
  37. @hide_header = true
  38. end
  39. def set_interaction_type
  40. @interaction_type = %w(reply reblog favourite).include?(params[:type]) ? params[:type] : 'reply'
  41. end
  42. end