Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Add admin and user setting for notifications #4339

Closed
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b9567f1
Add setting to set default notification alert level
alexbrazier Sep 17, 2016
a37e0d9
Add user preference for notifications
alexbrazier Sep 17, 2016
ac216b9
Add user preference for mobile notifications
alexbrazier Sep 17, 2016
997ab78
Change user notification preference string
alexbrazier Sep 17, 2016
3cc4ffb
Fix linting issues
alexbrazier Sep 17, 2016
4693c2d
Merge branch 'develop' into feature/default-notifications
alexbrazier Sep 17, 2016
a82ddbd
Add setting to disable notifications for all messages in large channels
alexbrazier Sep 18, 2016
81ffe23
Optimise queries for notifications
alexbrazier Sep 18, 2016
3f0af31
Optimise mongo query for large databases
alexbrazier Sep 18, 2016
060a64c
Merge branch 'develop' into feature/default-notifications
alexbrazier Sep 19, 2016
ff797c9
Merge branch 'develop' into feature/default-notifications
alexbrazier Oct 19, 2016
80dcfef
Update admin setting notification description to make it more clear
alexbrazier Oct 19, 2016
bd4e765
Merge branch 'develop' into feature/default-notifications
alexbrazier Dec 20, 2016
ec71055
Fix issue with notifications
alexbrazier Dec 20, 2016
ba79995
Merge branch 'develop' into feature/default-notifications
alexbrazier Jan 11, 2017
5825a26
Merge branch 'develop' into feature/default-notifications
alexbrazier Jan 28, 2017
16fb575
Merge branch 'develop' into feature/default-notifications
alexbrazier Feb 9, 2017
d57c907
Change lets to consts
alexbrazier Feb 9, 2017
883ac2a
Merge branch 'develop' into feature/default-notifications
alexbrazier Mar 7, 2017
9cd748b
Merge branch 'develop' into feature/default-notifications
alexbrazier Apr 2, 2017
42f668d
Merge branch 'develop' into pr/4339-alexbrazier-feature/default-notif…
marceloschmidt May 10, 2017
02541bb
Fix linting issues
alexbrazier May 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add user preference for notifications
  • Loading branch information
alexbrazier committed Sep 17, 2016
commit a37e0d99c7f25f735e6654c7ba9c72271bf0cc10
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
@@ -844,6 +844,7 @@
"Not_found_or_not_allowed" : "Not Found or Not Allowed",
"Nothing" : "Nothing",
"Nothing_found" : "Nothing found",
"Notification_Desktop_Default_For" : "Desktop Notifications For",
"Notification_Duration" : "Notification Duration",
"Notifications" : "Notifications",
"Notify_all_in_this_room" : "Notify all in this room",
Original file line number Diff line number Diff line change
@@ -74,9 +74,12 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
settings.dontNotifyMobileUsers = [];
settings.desktopNotificationDurations = {};
RocketChat.models.Subscriptions.findNotificationPreferencesByRoom(room._id).forEach(function(subscription) {
let currentUser = RocketChat.models.Users.findOneById(subscription.u._id);
let preferences = currentUser.settings ? currentUser.settings.preferences || {} : {};
let userDesktopNotificationPreference = preferences.desktopNotifications !== 'default' ? preferences.desktopNotifications : undefined;
// Set defaults if they don't exist
let {
desktopNotifications = RocketChat.settings.get('Desktop_Notifications_Default_Alert'),
desktopNotifications = userDesktopNotificationPreference || RocketChat.settings.get('Desktop_Notifications_Default_Alert'),
mobilePushNotifications = RocketChat.settings.get('Mobile_Notifications_Default_Alert')
} = subscription;

Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ Template.accountPreferences.onCreated ->
data.emailNotificationMode = $('select[name=emailNotificationMode]').val()
data.highlights = _.compact(_.map($('[name=highlights]').val().split(','), (e) -> return _.trim(e)))
data.desktopNotificationDuration = $('input[name=desktopNotificationDuration]').val()
data.desktopNotifications = $('#desktopNotifications').find('select').val()
data.unreadAlert = $('#unreadAlert').find('input:checked').val()

Meteor.call 'saveUserPreferences', data, (error, results) ->
11 changes: 11 additions & 0 deletions packages/rocketchat-ui-account/account/accountPreferences.html
Original file line number Diff line number Diff line change
@@ -52,6 +52,17 @@ <h1>{{_ "Messages"}}</h1>
{{/if}}
</div>
</div>
<div class="input-line double-col" id="desktopNotifications">
<label>{{_ "Notification_Desktop_Default_For"}}</label>
<div>
<select class="input-monitor" name="desktopNotifications">
<option value="default" selected="{{selected 'desktopNotifications' 'default' true}}">{{_ "Default"}}</option>
<option value="all" selected="{{selected 'desktopNotifications' 'all' false}}">{{_ "All"}}</option>
<option value="mentions" selected="{{selected 'desktopNotifications' 'mentions' false}}">{{_ "Mentions"}}</option>
<option value="nothing" selected="{{selected 'desktopNotifications' 'nothing' false}}">{{_ "Nothing"}}</option>
</select>
</div>
</div>
<div class="input-line double-col" id="unreadAlert">
<label>{{_ "Unread_Alert"}}</label>
<div>
3 changes: 3 additions & 0 deletions server/methods/saveUserPreferences.coffee
Original file line number Diff line number Diff line change
@@ -44,6 +44,9 @@ Meteor.methods
if settings.unreadAlert?
preferences.unreadAlert = if settings.unreadAlert is "1" then true else false

if settings.desktopNotifications?
preferences.desktopNotifications = settings.desktopNotifications;

preferences.desktopNotificationDuration = settings.desktopNotificationDuration - 0
preferences.viewMode = settings.viewMode || 0
preferences.hideUsernames = settings.hideUsernames is "1"