mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
closes #6465
This commit is contained in:
@@ -9,6 +9,7 @@ var meta = require('../../meta');
|
|||||||
var plugins = require('../../plugins');
|
var plugins = require('../../plugins');
|
||||||
var privileges = require('../../privileges');
|
var privileges = require('../../privileges');
|
||||||
var categories = require('../../categories');
|
var categories = require('../../categories');
|
||||||
|
var notifications = require('../../notifications');
|
||||||
var db = require('../../database');
|
var db = require('../../database');
|
||||||
var helpers = require('../helpers');
|
var helpers = require('../helpers');
|
||||||
var accountHelpers = require('./helpers');
|
var accountHelpers = require('./helpers');
|
||||||
@@ -180,15 +181,6 @@ settingsController.get = function (req, res, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getNotificationSettings(userData, callback) {
|
function getNotificationSettings(userData, callback) {
|
||||||
var types = [
|
|
||||||
'notificationType_upvote',
|
|
||||||
'notificationType_new-topic',
|
|
||||||
'notificationType_new-reply',
|
|
||||||
'notificationType_follow',
|
|
||||||
'notificationType_new-chat',
|
|
||||||
'notificationType_group-invite',
|
|
||||||
];
|
|
||||||
|
|
||||||
var privilegedTypes = [];
|
var privilegedTypes = [];
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
@@ -206,8 +198,7 @@ function getNotificationSettings(userData, callback) {
|
|||||||
privilegedTypes.push('notificationType_new-user-flag');
|
privilegedTypes.push('notificationType_new-user-flag');
|
||||||
}
|
}
|
||||||
plugins.fireHook('filter:user.notificationTypes', {
|
plugins.fireHook('filter:user.notificationTypes', {
|
||||||
userData: userData,
|
types: notifications.baseTypes.slice(),
|
||||||
types: types,
|
|
||||||
privilegedTypes: privilegedTypes,
|
privilegedTypes: privilegedTypes,
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ var async = require('async');
|
|||||||
|
|
||||||
var meta = require('../../meta');
|
var meta = require('../../meta');
|
||||||
var emailer = require('../../emailer');
|
var emailer = require('../../emailer');
|
||||||
var plugins = require('../../plugins');
|
var notifications = require('../../notifications');
|
||||||
|
|
||||||
var settingsController = module.exports;
|
var settingsController = module.exports;
|
||||||
|
|
||||||
@@ -45,32 +45,12 @@ function renderEmail(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderUser(req, res, next) {
|
function renderUser(req, res, next) {
|
||||||
var types = [
|
|
||||||
'notificationType_upvote',
|
|
||||||
'notificationType_new-topic',
|
|
||||||
'notificationType_new-reply',
|
|
||||||
'notificationType_follow',
|
|
||||||
'notificationType_new-chat',
|
|
||||||
'notificationType_group-invite',
|
|
||||||
];
|
|
||||||
|
|
||||||
var privilegedTypes = [
|
|
||||||
'notificationType_new-register',
|
|
||||||
'notificationType_post-queue',
|
|
||||||
'notificationType_new-post-flag',
|
|
||||||
'notificationType_new-user-flag',
|
|
||||||
];
|
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
plugins.fireHook('filter:user.notificationTypes', {
|
notifications.getAllNotificationTypes(next);
|
||||||
userData: {},
|
|
||||||
types: types,
|
|
||||||
privilegedTypes: privilegedTypes,
|
|
||||||
}, next);
|
|
||||||
},
|
},
|
||||||
function (results) {
|
function (notificationTypes) {
|
||||||
var notificationSettings = results.types.concat(results.privilegedTypes).map(function (type) {
|
var notificationSettings = notificationTypes.map(function (type) {
|
||||||
return {
|
return {
|
||||||
name: type,
|
name: type,
|
||||||
label: '[[notifications:' + type + ']]',
|
label: '[[notifications:' + type + ']]',
|
||||||
|
|||||||
@@ -17,6 +17,36 @@ var emailer = require('./emailer');
|
|||||||
|
|
||||||
var Notifications = module.exports;
|
var Notifications = module.exports;
|
||||||
|
|
||||||
|
Notifications.baseTypes = [
|
||||||
|
'notificationType_upvote',
|
||||||
|
'notificationType_new-topic',
|
||||||
|
'notificationType_new-reply',
|
||||||
|
'notificationType_follow',
|
||||||
|
'notificationType_new-chat',
|
||||||
|
'notificationType_group-invite',
|
||||||
|
];
|
||||||
|
|
||||||
|
Notifications.privilegedTypes = [
|
||||||
|
'notificationType_new-register',
|
||||||
|
'notificationType_post-queue',
|
||||||
|
'notificationType_new-post-flag',
|
||||||
|
'notificationType_new-user-flag',
|
||||||
|
];
|
||||||
|
|
||||||
|
Notifications.getAllNotificationTypes = function (callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
plugins.fireHook('filter:user.notificationTypes', {
|
||||||
|
types: Notifications.baseTypes.slice(),
|
||||||
|
privilegedTypes: Notifications.privilegedTypes.slice(),
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
function (results, next) {
|
||||||
|
next(null, results.types.concat(results.privilegedTypes));
|
||||||
|
},
|
||||||
|
], callback);
|
||||||
|
};
|
||||||
|
|
||||||
Notifications.startJobs = function () {
|
Notifications.startJobs = function () {
|
||||||
winston.verbose('[notifications.init] Registering jobs.');
|
winston.verbose('[notifications.init] Registering jobs.');
|
||||||
new cron('*/30 * * * *', Notifications.prune, null, true);
|
new cron('*/30 * * * *', Notifications.prune, null, true);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var async = require('async');
|
|||||||
var meta = require('../meta');
|
var meta = require('../meta');
|
||||||
var db = require('../database');
|
var db = require('../database');
|
||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
|
var notifications = require('../notifications');
|
||||||
|
|
||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
User.getSettings = function (uid, callback) {
|
User.getSettings = function (uid, callback) {
|
||||||
@@ -81,12 +82,14 @@ module.exports = function (User) {
|
|||||||
settings.delayImageLoading = parseInt(getSetting(settings, 'delayImageLoading', 1), 10) === 1;
|
settings.delayImageLoading = parseInt(getSetting(settings, 'delayImageLoading', 1), 10) === 1;
|
||||||
settings.bootswatchSkin = settings.bootswatchSkin || meta.config.bootswatchSkin || 'default';
|
settings.bootswatchSkin = settings.bootswatchSkin || meta.config.bootswatchSkin || 'default';
|
||||||
settings.scrollToMyPost = parseInt(getSetting(settings, 'scrollToMyPost', 1), 10) === 1;
|
settings.scrollToMyPost = parseInt(getSetting(settings, 'scrollToMyPost', 1), 10) === 1;
|
||||||
settings.notificationType_upvote = getSetting(settings, 'notificationType_upvote', 'notification');
|
|
||||||
settings['notificationType_new-topic'] = getSetting(settings, 'notificationType_new-topic', 'notification');
|
notifications.getAllNotificationTypes(next);
|
||||||
settings['notificationType_new-reply'] = getSetting(settings, 'notificationType_new-reply', 'notification');
|
},
|
||||||
settings.notificationType_follow = getSetting(settings, 'notificationType_follow', 'notification');
|
function (notificationTypes, next) {
|
||||||
settings['notificationType_new-chat'] = getSetting(settings, 'notificationType_new-chat', 'notification');
|
notificationTypes.forEach(function (notificationType) {
|
||||||
settings['notificationType_group-invite'] = getSetting(settings, 'notificationType_group-invite', 'notification');
|
settings[notificationType] = getSetting(settings, notificationType, 'notification');
|
||||||
|
});
|
||||||
|
|
||||||
next(null, settings);
|
next(null, settings);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
@@ -139,26 +142,20 @@ module.exports = function (User) {
|
|||||||
upvoteNotifFreq: data.upvoteNotifFreq,
|
upvoteNotifFreq: data.upvoteNotifFreq,
|
||||||
};
|
};
|
||||||
|
|
||||||
var notificationTypes = [
|
|
||||||
'notificationType_upvote', 'notificationType_new-topic', 'notificationType_new-reply',
|
|
||||||
'notificationType_follow', 'notificationType_new-chat', 'notificationType_group-invite',
|
|
||||||
'notificationType_new-register', 'notificationType_post-queue', 'notificationType_new-post-flag',
|
|
||||||
'notificationType_new-user-flag',
|
|
||||||
];
|
|
||||||
|
|
||||||
notificationTypes.forEach(function (notificationType) {
|
|
||||||
if (data[notificationType]) {
|
|
||||||
settings[notificationType] = data[notificationType];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (data.bootswatchSkin) {
|
if (data.bootswatchSkin) {
|
||||||
settings.bootswatchSkin = data.bootswatchSkin;
|
settings.bootswatchSkin = data.bootswatchSkin;
|
||||||
}
|
}
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
|
notifications.getAllNotificationTypes(next);
|
||||||
|
},
|
||||||
|
function (notificationTypes, next) {
|
||||||
|
notificationTypes.forEach(function (notificationType) {
|
||||||
|
if (data[notificationType]) {
|
||||||
|
settings[notificationType] = data[notificationType];
|
||||||
|
}
|
||||||
|
});
|
||||||
plugins.fireHook('filter:user.saveSettings', { settings: settings, data: data }, next);
|
plugins.fireHook('filter:user.saveSettings', { settings: settings, data: data }, next);
|
||||||
},
|
},
|
||||||
function (result, next) {
|
function (result, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user