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.

34 lines
681 B

  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'].gsub(/\Aacct:/, ''))
  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