]> cat aescling's git repositories - mastodon.git/blob - app/controllers/settings/preferences_controller.rb
Fix #65 - Options to block notifications from people you don't follow/who don't follo...
[mastodon.git] / app / controllers / settings / preferences_controller.rb
1 # frozen_string_literal: true
2
3 class Settings::PreferencesController < ApplicationController
4 layout 'auth'
5
6 before_action :authenticate_user!
7
8 def show
9 end
10
11 def update
12 current_user.settings(:notification_emails).follow = user_params[:notification_emails][:follow] == '1'
13 current_user.settings(:notification_emails).reblog = user_params[:notification_emails][:reblog] == '1'
14 current_user.settings(:notification_emails).favourite = user_params[:notification_emails][:favourite] == '1'
15 current_user.settings(:notification_emails).mention = user_params[:notification_emails][:mention] == '1'
16
17 current_user.settings(:interactions).must_be_follower = user_params[:interactions][:must_be_follower] == '1'
18 current_user.settings(:interactions).must_be_following = user_params[:interactions][:must_be_following] == '1'
19
20 if current_user.update(user_params.except(:notification_emails, :interactions))
21 redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg')
22 else
23 render action: :show
24 end
25 end
26
27 private
28
29 def user_params
30 params.require(:user).permit(:locale, notification_emails: [:follow, :reblog, :favourite, :mention], interactions: [:must_be_follower, :must_be_following])
31 end
32 end
This page took 0.083598 seconds and 4 git commands to generate.