intents_controller.rb 684 B

12345678910111213141516171819202122232425262728293031323334
  1. # frozen_string_literal: true
  2. class IntentsController < ApplicationController
  3. before_action :check_uri
  4. rescue_from Addressable::URI::InvalidURIError, with: :handle_invalid_uri
  5. def show
  6. if uri.scheme == 'web+mastodon'
  7. case uri.host
  8. when 'follow'
  9. return redirect_to authorize_interaction_path(uri: uri.query_values['uri'].delete_prefix('acct:'))
  10. when 'share'
  11. return redirect_to share_path(text: uri.query_values['text'])
  12. end
  13. end
  14. not_found
  15. end
  16. private
  17. def check_uri
  18. not_found if uri.blank?
  19. end
  20. def handle_invalid_uri
  21. not_found
  22. end
  23. def uri
  24. @uri ||= Addressable::URI.parse(params[:uri])
  25. end
  26. end