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.
 
 
 
 

54 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. def new
  10. @remote_follow = RemoteFollow.new(session_params)
  11. end
  12. def create
  13. @remote_follow = RemoteFollow.new(resource_params)
  14. if @remote_follow.valid?
  15. session[:remote_follow] = @remote_follow.acct
  16. redirect_to @remote_follow.interact_address_for(@status)
  17. else
  18. render :new
  19. end
  20. end
  21. private
  22. def resource_params
  23. params.require(:remote_follow).permit(:acct)
  24. end
  25. def session_params
  26. { acct: session[:remote_follow] || current_account&.username }
  27. end
  28. def set_status
  29. @status = Status.find(params[:id])
  30. authorize @status, :show?
  31. rescue Mastodon::NotPermittedError
  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_interaction_type
  39. @interaction_type = %w(reply reblog favourite).include?(params[:type]) ? params[:type] : 'reply'
  40. end
  41. end