Skip to content

Node.js based forum software built for the modern web

Add notification frequencies from nodebb-plugin-upvote-notifications. (#6640)

Ben Lubarf1a6537fc2da
diff --git a/public/language/en-GB/user.json b/public/language/en-GB/user.json
index d69941be5d..b971fc682c 100644
--- a/public/language/en-GB/user.json
+++ b/public/language/en-GB/user.json
@@ -117,7 +117,9 @@
"no-sound": "No sound",
"upvote-notif-freq": "Upvote Notification Frequency",
"upvote-notif-freq.all": "All Upvotes",
+ "upvote-notif-freq.first": "First Per Post",
"upvote-notif-freq.everyTen": "Every Ten Upvotes",
+ "upvote-notif-freq.threshold": "On 1, 5, 10, 25, 50, 100, 150, 200...",
"upvote-notif-freq.logarithmic": "On 10, 100, 1000...",
"upvote-notif-freq.disabled": "Disabled",
diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js
index 5f5bb57aa7..0beab3f77a 100644
--- a/src/controllers/accounts/settings.js
+++ b/src/controllers/accounts/settings.js
@@ -148,7 +148,9 @@ settingsController.get = function (req, res, callback) {
var notifFreqOptions = [
'all',
+ 'first',
'everyTen',
+ 'threshold',
'logarithmic',
'disabled',
];
@@ -156,7 +158,7 @@ settingsController.get = function (req, res, callback) {
userData.upvoteNotifFreq = notifFreqOptions.map(function (name) {
return {
name: name,
- selected: name === userData.notifFreqOptions,
+ selected: name === userData.settings.upvoteNotifFreq,
};
});
diff --git a/src/socket.io/helpers.js b/src/socket.io/helpers.js
index 4679b73598..163e7d54d3 100644
--- a/src/socket.io/helpers.js
+++ b/src/socket.io/helpers.js
@@ -186,9 +186,15 @@ SocketHelpers.upvote = function (data, notification) {
all: function () {
return votes > 0;
},
+ first: function () {
+ return votes === 1;
+ },
everyTen: function () {
return votes > 0 && votes % 10 === 0;
},
+ threshold: function () {
+ return [1, 5, 10, 25].indexOf(votes) !== -1 || (votes >= 50 && votes % 50 === 0);
+ },
logarithmic: function () {
return votes > 1 && Math.log10(votes) % 1 === 0;
},