about summary refs log tree commit diff
path: root/app/controllers/intents_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-08-14 04:53:31 +0200
committerGitHub <noreply@github.com>2017-08-14 04:53:31 +0200
commit3c6503038ecad20f1b8fa0c9ea7e46087c6e3f22 (patch)
tree3da0736f8e6643260c8cea7176e583fcb0c46575 /app/controllers/intents_controller.rb
parent96e9ed13ded6def1d96260178ee9d9e7ad3e5d23 (diff)
Add protocol handler. Handle follow intents (#4511)
* Add protocol handler. Handle follow intents

* Add share intent

* Improve code in intents controller

* Adjust share form CSS
Diffstat (limited to 'app/controllers/intents_controller.rb')
-rw-r--r--app/controllers/intents_controller.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/controllers/intents_controller.rb b/app/controllers/intents_controller.rb
new file mode 100644
index 000000000..504befd1f
--- /dev/null
+++ b/app/controllers/intents_controller.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class IntentsController < ApplicationController
+  def show
+    uri = Addressable::URI.parse(params[:uri])
+
+    if uri.scheme == 'web+mastodon'
+      case uri.host
+      when 'follow'
+        return redirect_to authorize_follow_path(acct: uri.query_values['uri'].gsub(/\Aacct:/, ''))
+      when 'share'
+        return redirect_to share_path(text: uri.query_values['text'])
+      end
+    end
+
+    not_found
+  end
+end