about summary refs log tree commit diff
path: root/app/controllers/api/v1
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-01-29 01:30:32 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-01-29 01:30:32 +0100
commit3f075c7794ca7cc6e3c566591e9929859c6c325c (patch)
treefd649accdafbb57cf1ac5d7231dd44bd5dd447c8 /app/controllers/api/v1
parent1992575d577bf5b4c408a0104ad310e17846466a (diff)
API for apps to register for push notifications
Diffstat (limited to 'app/controllers/api/v1')
-rw-r--r--app/controllers/api/v1/devices_controller.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/controllers/api/v1/devices_controller.rb b/app/controllers/api/v1/devices_controller.rb
new file mode 100644
index 000000000..c565e972b
--- /dev/null
+++ b/app/controllers/api/v1/devices_controller.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class Api::V1::DevicesController < ApiController
+  before_action -> { doorkeeper_authorize! :read }
+  before_action :require_user!
+
+  respond_to :json
+
+  def register
+    Device.where(account: current_account, registration_id: params[:registration_id]).first_or_create!(account: current_account, registration_id: params[:registration_id])
+    render_empty
+  end
+
+  def unregister
+    Device.where(account: current_account, registration_id: params[:registration_id]).delete_all
+    render_empty
+  end
+end