~cytrogen/masto-fe

ref: 3ca94f6d4a99cdf7f99eefd7d26a18a82c3c6f78 masto-fe/app/controllers/intents_controller.rb -rw-r--r-- 684 bytes
3ca94f6d — Claire Merge commit '93d051e47d27b5bd10be922a81d4d4eb6c306330' into glitch-soc/merge-upstream 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

class IntentsController < ApplicationController
  before_action :check_uri

  rescue_from Addressable::URI::InvalidURIError, with: :handle_invalid_uri

  def show
    if uri.scheme == 'web+mastodon'
      case uri.host
      when 'follow'
        return redirect_to authorize_interaction_path(uri: uri.query_values['uri'].delete_prefix('acct:'))
      when 'share'
        return redirect_to share_path(text: uri.query_values['text'])
      end
    end

    not_found
  end

  private

  def check_uri
    not_found if uri.blank?
  end

  def handle_invalid_uri
    not_found
  end

  def uri
    @uri ||= Addressable::URI.parse(params[:uri])
  end
end