Skip to content

Node.js based forum software built for the modern web

feat: allow disabling all notification emails, closes #5644

Barış Soner Uşaklı46ac1ee623a7
diff --git a/install/data/defaults.json b/install/data/defaults.json
index 7bb41c5dc3..fde027c5e7 100644
--- a/install/data/defaults.json
+++ b/install/data/defaults.json
@@ -169,6 +169,7 @@
"emailConfirmInterval": 10,
"emailConfirmExpiry": 24,
"removeEmailNotificationImages": 0,
+ "disableNotificationEmails": 0,
"sendValidationEmail": 1,
"includeUnverifiedEmails": 0,
"emailPrompt": 1,
diff --git a/install/package.json b/install/package.json
index bf354e78e9..c305a17cd3 100644
--- a/install/package.json
+++ b/install/package.json
@@ -113,10 +113,10 @@
"nodebb-plugin-spam-be-gone": "2.3.5",
"nodebb-plugin-web-push": "0.9.3",
"nodebb-rewards-essentials": "1.0.3",
- "nodebb-theme-harmony": "3.2.11",
+ "nodebb-theme-harmony": "3.2.12",
"nodebb-theme-lavender": "8.1.0",
"nodebb-theme-peace": "3.1.3",
- "nodebb-theme-persona": "15.2.7",
+ "nodebb-theme-persona": "15.2.8",
"nodebb-widget-essentials": "8.0.9",
"nodemailer": "9.0.5",
"nprogress": "0.2.0",
diff --git a/public/language/en-GB/admin/settings/notifications.json b/public/language/en-GB/admin/settings/notifications.json
index ea422da765..d1eab6aee6 100644
--- a/public/language/en-GB/admin/settings/notifications.json
+++ b/public/language/en-GB/admin/settings/notifications.json
@@ -1,5 +1,6 @@
{
"notifications": "Notifications",
+ "disable-notification-emails": "Disable Notification Emails",
"welcome-notification": "Welcome Notification",
"welcome-notification-link": "Welcome Notification Link",
"welcome-notification-uid": "Welcome Notification User (UID)",
diff --git a/public/openapi/read/user/userslug/settings.yaml b/public/openapi/read/user/userslug/settings.yaml
index 01bfe7c2bd..0800cc4128 100644
--- a/public/openapi/read/user/userslug/settings.yaml
+++ b/public/openapi/read/user/userslug/settings.yaml
@@ -85,6 +85,8 @@ get:
type: boolean
disableEmailSubscriptions:
type: number
+ disableNotificationEmails:
+ type: number
dailyDigestFreqOptions:
type: array
items:
diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js
index 85ba78e06a..331fad7508 100644
--- a/src/controllers/accounts/settings.js
+++ b/src/controllers/accounts/settings.js
@@ -51,6 +51,7 @@ settingsController.get = async function (req, res, next) {
userData.bootswatchSkinOptions = bsSkinOptions;
userData.notificationSettings = notificationSettings;
userData.disableEmailSubscriptions = meta.config.disableEmailSubscriptions;
+ userData.disableNotificationEmails = meta.config.disableNotificationEmails;
userData.dailyDigestFreqOptions = [
{ value: 'off', name: '[[user:digest-off]]', selected: userData.settings.dailyDigestFreq === 'off' },
diff --git a/src/notifications.js b/src/notifications.js
index c96a309406..342c28c84e 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -270,11 +270,11 @@ async function pushToUids(uids, notification) {
uidsToNotify.push(userSettings.uid);
}
- if (setting === 'email' || setting === 'notificationemail') {
+ if (!meta.config.disableNotificationEmails && (setting === 'email' || setting === 'notificationemail')) {
uidsToEmail.push(userSettings.uid);
}
});
- return { uidsToNotify: uidsToNotify, uidsToEmail: uidsToEmail };
+ return { uidsToNotify, uidsToEmail };
}
// Remove uid from recipients list if they have blocked the user triggering the notification
diff --git a/src/views/admin/settings/notifications.tpl b/src/views/admin/settings/notifications.tpl
index 1bd43e398f..8929d5e5a8 100644
--- a/src/views/admin/settings/notifications.tpl
+++ b/src/views/admin/settings/notifications.tpl
@@ -5,6 +5,11 @@
<div id="spy-container" class="col-12 col-md-8 px-0 mb-4" tabindex="0">
<div id="notifications" class="mb-4">
<h5 class="fw-bold tracking-tight settings-header hidden">{{tx("admin/settings/notifications:notifications")}}</h5>
+ <div class="form-check form-switch mb-3">
+ <input class="form-check-input" type="checkbox" id="disableNotificationEmails" data-field="disableNotificationEmails">
+ <label for="disableNotificationEmails" class="form-check-label">{{tx("admin/settings/notifications:disable-notification-emails")}}</label>
+ </div>
+
<div class="mb-3">
<label class="form-label">{{tx("admin/settings/notifications:welcome-notification")}}</label>
<textarea class="form-control" data-field="welcomeNotification"></textarea>