about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-10-04 17:22:52 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-10-04 10:22:52 +0200
commit178f718a9b1cab57fbd9df511abe56533f12e129 (patch)
tree84ccf253df169339f711a7730e5b7c399a58f446 /app/controllers
parent0e1b0f2747af373e3d51251337f40bfff13ef160 (diff)
Separate notifications preferences from general preferences (#4447)
* Separate notifications preferences from general preferences

* Refine settings/notifications/show

* remove preferences.notifications
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/settings/notifications_controller.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/settings/notifications_controller.rb b/app/controllers/settings/notifications_controller.rb
new file mode 100644
index 000000000..09839f16e
--- /dev/null
+++ b/app/controllers/settings/notifications_controller.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+class Settings::NotificationsController < ApplicationController
+  layout 'admin'
+
+  before_action :authenticate_user!
+
+  def show; end
+
+  def update
+    user_settings.update(user_settings_params.to_h)
+
+    if current_user.save
+      redirect_to settings_notifications_path, notice: I18n.t('generic.changes_saved_msg')
+    else
+      render :show
+    end
+  end
+
+  private
+
+  def user_settings
+    UserSettingsDecorator.new(current_user)
+  end
+
+  def user_settings_params
+    params.require(:user).permit(
+      notification_emails: %i(follow follow_request reblog favourite mention digest),
+      interactions: %i(must_be_follower must_be_following)
+    )
+  end
+end