about summary refs log tree commit diff
path: root/app/controllers/shares_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/shares_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/shares_controller.rb')
-rw-r--r--app/controllers/shares_controller.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb
new file mode 100644
index 000000000..d70d66ff8
--- /dev/null
+++ b/app/controllers/shares_controller.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class SharesController < ApplicationController
+  layout 'public'
+
+  before_action :authenticate_user!
+
+  def show
+    serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
+    @initial_state_json   = serializable_resource.to_json
+  end
+
+  private
+
+  def initial_state_params
+    {
+      settings: Web::Setting.find_by(user: current_user)&.data || {},
+      push_subscription: current_account.user.web_push_subscription(current_session),
+      current_account: current_account,
+      token: current_session.token,
+      admin: Account.find_local(Setting.site_contact_username),
+      text: params[:text],
+    }
+  end
+end