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 ability to disable email notifications globally #9667

Merged
merged 14 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions app/lib/server/functions/notifications/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ export function shouldNotifyEmail({
hasReplyToThread,
roomType,
}) {
// email notifications are disabled globally
if (!settings.get('Accounts_AllowEmailNotifications')) {
return false;
}

// use connected (don't need to send him an email)
if (statusConnection === 'online') {
return false;
Expand Down
4 changes: 4 additions & 0 deletions app/lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ settings.addGroup('Accounts', function() {
type: 'boolean',
public: true,
});
this.add('Accounts_AllowEmailNotifications', true, {
type: 'boolean',
public: true,
});
this.add('Accounts_CustomFieldsToShowInUserInfo', '', {
type: 'string',
public: true,
Expand Down
24 changes: 15 additions & 9 deletions app/ui-account/client/accountPreferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,21 @@ <h1>{{_ "Notifications"}}</h1>
<div class="input-line double-col" id="emailNotificationMode">
<label class="setting-label">{{_ "Email_Notification_Mode"}}</label>
<div class="setting-field">
<div class="rc-select">
<select class="input-monitor rc-select__element" name="emailNotificationMode">
<option value="default" selected="{{selected 'emailNotificationMode' 'default' 'default'}}">{{_ "Default"}} ({{_ defaultEmailNotification}})</option>
<option value="nothing" selected="{{selected 'emailNotificationMode' 'nothing'}}">{{_ "Email_Notification_Mode_Disabled"}}</option>
<option value="mentions" selected="{{selected 'emailNotificationMode' 'mentions'}}">{{_ "Email_Notification_Mode_All"}}</option>
</select>
{{> icon block="rc-select__arrow" icon="arrow-down" }}
</div>
<div class="settings-description secondary-font-color">{{_ "You_need_to_verifiy_your_email_address_to_get_notications"}}</div>
{{#with canChange=emailNotificationsAllowed}}
<div class="rc-select">
<select class="input-monitor rc-select__element" name="emailNotificationMode" {{ifThenElse canChange '' 'disabled'}}>
<option value="default" selected="{{selected 'emailNotificationMode' 'default' 'default'}}">{{_ "Default"}} ({{_ defaultEmailNotification}})</option>
<option value="nothing" selected="{{selected 'emailNotificationMode' 'nothing'}}">{{_ "Email_Notification_Mode_Disabled"}}</option>
<option value="mentions" selected="{{selected 'emailNotificationMode' 'mentions'}}">{{_ "Email_Notification_Mode_All"}}</option>
</select>
{{> icon block="rc-select__arrow" icon="arrow-down" }}
</div>
{{#if canChange}}
<div class="settings-description secondary-font-color">{{_ "You_need_to_verifiy_your_email_address_to_get_notications"}}</div>
{{else}}
<div class="info">{{_ "Email_Notifications_Change_Disabled"}}</div>
{{/if}}
{{/with}}
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions app/ui-account/client/accountPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Template.accountPreferences.helpers({
const languageKey = Meteor.user().language;
return typeof languageKey === 'string' && languageKey.toLowerCase() === key;
},
ifThenElse(condition, val, not = '') {
return condition ? val : not;
},
checked(property, value, defaultValue = undefined) {
return checkedSelected(property, value, defaultValue);
},
Expand Down Expand Up @@ -111,6 +114,9 @@ Template.accountPreferences.helpers({
notificationsSoundVolume() {
return getUserPreference(Meteor.userId(), 'notificationsSoundVolume');
},
emailNotificationsAllowed() {
return settings.get('Accounts_AllowEmailNotifications');
},
dontAskAgainList() {
return getUserPreference(Meteor.userId(), 'dontAskAgainList');
},
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/de.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"Accounts_AllowedDomainsList": "Liste von erlaubten Domains",
"Accounts_AllowedDomainsList_Description": "Durch Kommata getrennte Liste von erlaubten Domains",
"Accounts_AllowEmailChange": "Ändern der E-Mail-Adresse erlauben",
"Accounts_AllowEmailNotifications": "Offline-E-Mail-Benachrichtigungen erlauben",
"Accounts_AllowPasswordChange": "Ändern des Passworts erlauben",
"Accounts_AllowRealNameChange": "Ändern des Namens erlauben",
"Accounts_AllowUserAvatarChange": "Benutzern das Ändern des Profilbilds erlauben",
Expand Down Expand Up @@ -1166,6 +1167,7 @@
"Email_Footer_Description": "Sie können die folgenden Platzhalter verwenden: <br/><ul><li> [Site_Name] und [Site_URL] für den Anwendungsname und die URL. </li></ul>",
"Email_from": "Absender",
"Email_Header_Description": "Sie können die folgenden Platzhalter verwenden: <br/><ul><li> [Site_Name] und [Site_URL] für den Anwendungsname und die URL. </li></ul>",
"Email_Notifications_Change_Disabled": "Der Rocket.Chat Administrator hat Offline-E-Mail-Benachrichtigungen deaktiviert",
"Email_Notification_Mode": "Offline-E-Mail-Benachrichtigungen",
"Email_Notification_Mode_All": "Jede Erwähnung/DM",
"Email_Notification_Mode_Disabled": "deaktiviert",
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"Accounts_AllowedDomainsList": "Allowed Domains List",
"Accounts_AllowedDomainsList_Description": "Comma-separated list of allowed domains",
"Accounts_AllowEmailChange": "Allow Email Change",
"Accounts_AllowEmailNotifications": "Allow Email Notifications",
"Accounts_AllowPasswordChange": "Allow Password Change",
"Accounts_AllowRealNameChange": "Allow Name Change",
"Accounts_AllowUserAvatarChange": "Allow User Avatar Change",
Expand Down Expand Up @@ -1177,6 +1178,7 @@
"Email_Change_Disabled": "Your Rocket.Chat administrator has disabled the changing of email",
"Email_Footer_Description": "You may use the following placeholders: <br/><ul><li>[Site_Name] and [Site_URL] for the Application Name and URL respectively.</li></ul>",
"Email_from": "From",
"Email_Notifications_Change_Disabled": "Your Rocket.Chat administrator has disabled email notifications",
"Email_Header_Description": "You may use the following placeholders: <br/><ul><li>[Site_Name] and [Site_URL] for the Application Name and URL respectively.</li></ul>",
"Email_Notification_Mode": "Offline Email Notifications",
"Email_Notification_Mode_All": "Every Mention/DM",
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/fr.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"Accounts_AllowedDomainsList": "Liste des domaines autorisés",
"Accounts_AllowedDomainsList_Description": "Liste des domaines autorisés, séparés par des virgules",
"Accounts_AllowEmailChange": "Autoriser le changement d'adresse e-mail",
"Accounts_AllowEmailNotifications": "Autoriser les notifications hors-ligne par e-mail",
"Accounts_AllowPasswordChange": "Autoriser le changement de mot de passe",
"Accounts_AllowRealNameChange": "Permettre le changement de nom",
"Accounts_AllowUserAvatarChange": "Autoriser le changement d'avatar",
Expand Down Expand Up @@ -1080,6 +1081,7 @@
"Email_Footer_Description": "Vous pouvez utiliser les variables suivantes: <br/><ul><li> [Site_Name] et [Site_URL] pour le nom de l'application et URL respectivement. </li></ul>",
"Email_from": "De",
"Email_Header_Description": "Vous pouvez utiliser les variables suivantes: <br/><ul><li> [Site_Name] et [Site_URL] pour le nom de l'application et URL respectivement. </li></ul>",
"Email_Notifications_Change_Disabled": "Votre administrateur de Rocket.Chat a désactivé les notifications hors-ligne par e-mail",
"Email_Notification_Mode": "Notifications hors-ligne par e-mail",
"Email_Notification_Mode_All": "Toutes les Mentions/MP",
"Email_Notification_Mode_Disabled": "Désactivé",
Expand Down