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