Skip to content
Snippets Groups Projects
Commit 19bf528f authored by TheConnMan's avatar TheConnMan
Browse files

Change offline email preference to a select box

parent cf74dafb
No related branches found
No related tags found
No related merge requests found
......@@ -163,7 +163,9 @@
"edited" : "edited",
"Email_already_exists" : "Email already exists",
"Email_Change_Disabled" : "Your Rocket.Chat administrator has disabled the changing of e-mail",
"Email_Notification_Mode" : "Email Notifications On",
"Email_Notification_Mode" : "Offline Email Notifications",
"Email_Notification_Mode_Disabled" : "Disabled",
"Email_Notification_Mode_All" : "Every Mention/DM",
"Email_or_username" : "Email or username",
"Email_verified" : "Email verified",
"Emoji" : "Emoji",
......
......@@ -79,7 +79,7 @@ RocketChat.sendMessage = (user, message, room, options) ->
query:
userId: userOfMention._id
if userOfMention.status is 'offline' and userOfMention.settings?.preferences?.emailNotificationMode is true and userOfMention.emails and userOfMention.emails.length > 0
if userOfMention.status is 'offline' and !(userOfMention.settings?.preferences?.emailNotificationMode is 'disabled') and userOfMention.emails and userOfMention.emails.length > 0
Email.send
to: userOfMention.emails[0].address
from: RocketChat.settings.get('From_Email')
......@@ -119,7 +119,7 @@ RocketChat.sendMessage = (user, message, room, options) ->
userIdsToPushNotify = userIdsToNotify
offlineMentionsRoom = _.filter usersOfMention, (user) ->
user.status is 'offline' and user.settings?.preferences?.emailNotificationMode is true
user.status is 'offline' and !(user.settings?.preferences?.emailNotificationMode is 'disabled')
# If the message is @all, notify all room users except for the sender.
if toAll and room.usernames?.length > 0
......@@ -133,7 +133,7 @@ RocketChat.sendMessage = (user, message, room, options) ->
userIdsToNotify = _.union userIdsToNotify, _.pluck(onlineUsersOfRoom, '_id')
userIdsToPushNotify = _.union userIdsToPushNotify, _.pluck(usersOfRoom, '_id')
offlineMentionsRoom = _.filter usersOfRoom, (user) ->
user.status is 'offline' and user.settings?.preferences?.emailNotificationMode is true
user.status is 'offline' and !(user.settings?.preferences?.emailNotificationMode is 'disabled')
if userIdsToNotify.length > 0
for usersOfMentionId in userIdsToNotify
......
......@@ -7,6 +7,12 @@ Template.accountPreferences.helpers
return currentValue is value
selected: (property, value, defaultValue) ->
if not Meteor.user()?.settings?.preferences?[property]
return defaultValue
else
return Meteor.user()?.settings?.preferences?[property] == value
desktopNotificationEnabled: ->
return (KonchatNotification.notificationStatus.get() is 'granted') or (window.Notification && Notification.permission is "granted")
......@@ -42,7 +48,7 @@ Template.accountPreferences.onCreated ->
data.compactView = $('input[name=compactView]:checked').val()
data.unreadRoomsMode = $('input[name=unreadRoomsMode]:checked').val()
data.autoImageLoad = $('input[name=autoImageLoad]:checked').val()
data.emailNotificationMode = $('input[name=emailNotificationMode]:checked').val()
data.emailNotificationMode = $('select[name=emailNotificationMode]').val()
Meteor.call 'saveUserPreferences', data, (error, results) ->
if results
......
......@@ -71,8 +71,10 @@
<div class="input-line double-col" id="emailNotificationMode">
<label>{{_ "Email_Notification_Mode"}}</label>
<div>
<label><input type="radio" name="emailNotificationMode" value="1" checked="{{checked 'emailNotificationMode' true true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="emailNotificationMode" value="0" checked="{{checked 'emailNotificationMode' false}}" /> {{_ "False"}}</label>
<select class="input-monitor" name="emailNotificationMode">
<option value="disabled" selected="{{selected 'emailNotificationMode' 'disabled' false}}">{{_ "Email_Notification_Mode_Disabled"}}</option>
<option value="all" selected="{{selected 'emailNotificationMode' 'all' true}}">{{_ "Email_Notification_Mode_All"}}</option>
</select>
</div>
</div>
</div>
......
......@@ -28,7 +28,7 @@ Meteor.methods
preferences.autoImageLoad = if settings.autoImageLoad is "1" then true else false
if settings.emailNotificationMode?
preferences.emailNotificationMode = if settings.emailNotificationMode is "1" then true else false
preferences.emailNotificationMode = settings.emailNotificationMode
RocketChat.models.Users.setPreferences Meteor.userId(), preferences
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment