mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 11:47:22 +02:00
booleanifying sendPostNotification user setting when requested, and now only sending the post notification if the user has flipped that option on in user settings... kind of an important thing to forget...
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
var async = require('async'),
|
||||
nconf = require('nconf'),
|
||||
S = require('string'),
|
||||
winston = require('winston'),
|
||||
|
||||
db = require('../database'),
|
||||
user = require('../user'),
|
||||
@@ -133,16 +134,20 @@ module.exports = function(Topics) {
|
||||
userData: async.apply(user.getUserFields, toUid, ['username']),
|
||||
userSettings: async.apply(user.getSettings, toUid)
|
||||
}, function(err, data) {
|
||||
emailer.send('notif_post', toUid, {
|
||||
pid: postData.pid,
|
||||
subject: '[' + (meta.config.title || 'NodeBB') + '] ' + title,
|
||||
intro: '[[notifications:user_posted_to, ' + postData.user.username + ', ' + title + ']]',
|
||||
postBody: postData.content,
|
||||
site_title: meta.config.title || 'NodeBB',
|
||||
username: data.userData.username,
|
||||
url: nconf.get('url') + '/topics/' + postData.topic.tid,
|
||||
base_url: nconf.get('url')
|
||||
}, next);
|
||||
if (data.userSettings.hasOwnProperty('sendPostNotifications') && data.userSettings.sendPostNotifications) {
|
||||
emailer.send('notif_post', toUid, {
|
||||
pid: postData.pid,
|
||||
subject: '[' + (meta.config.title || 'NodeBB') + '] ' + title,
|
||||
intro: '[[notifications:user_posted_to, ' + postData.user.username + ', ' + title + ']]',
|
||||
postBody: postData.content,
|
||||
site_title: meta.config.title || 'NodeBB',
|
||||
username: data.userData.username,
|
||||
url: nconf.get('url') + '/topics/' + postData.topic.tid,
|
||||
base_url: nconf.get('url')
|
||||
}, next);
|
||||
} else {
|
||||
winston.debug('[topics.notifyFollowers] uid ' + toUid + ' does not have post notifications enabled, skipping.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,6 +69,7 @@ module.exports = function(User) {
|
||||
settings.followTopicsOnCreate = (settings.followTopicsOnCreate === null || settings.followTopicsOnCreate === undefined) ? true : parseInt(settings.followTopicsOnCreate, 10) === 1;
|
||||
settings.followTopicsOnReply = parseInt(settings.followTopicsOnReply, 10) === 1;
|
||||
settings.sendChatNotifications = parseInt(settings.sendChatNotifications, 10) === 1;
|
||||
settings.sendPostNotifications = parseInt(settings.sendPostNotifications, 10) === 1;
|
||||
settings.restrictChat = parseInt(settings.restrictChat, 10) === 1;
|
||||
settings.topicSearchEnabled = parseInt(settings.topicSearchEnabled, 10) === 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user