Files
NodeBB/src/controllers/admin/settings.js

85 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-09-17 16:25:15 -04:00
'use strict';
2016-10-31 13:52:26 +03:00
var async = require('async');
2016-10-31 13:52:26 +03:00
var meta = require('../../meta');
var emailer = require('../../emailer');
var plugins = require('../../plugins');
2016-10-31 13:52:26 +03:00
var settingsController = module.exports;
2015-09-17 16:25:15 -04:00
settingsController.get = function (req, res, next) {
2015-09-17 16:25:15 -04:00
var term = req.params.term ? req.params.term : 'general';
switch (req.params.term) {
2017-02-18 02:38:03 -07:00
case 'email':
renderEmail(req, res, next);
break;
case 'user':
renderUser(req, res, next);
break;
2017-02-18 02:38:03 -07:00
default:
res.render('admin/settings/' + term);
}
2015-09-17 16:25:15 -04:00
};
function renderEmail(req, res, next) {
async.waterfall([
function (next) {
async.parallel({
emails: async.apply(emailer.getTemplates, meta.config),
services: emailer.listServices,
}, next);
},
function (results) {
res.render('admin/settings/email', {
emails: results.emails,
sendable: results.emails.filter(function (email) {
return email.path.indexOf('_plaintext') === -1 && email.path.indexOf('partials') === -1;
}),
services: results.services,
});
},
], next);
}
function renderUser(req, res, next) {
var types = [
'notificationType_upvote',
'notificationType_new-topic',
'notificationType_new-reply',
'notificationType_follow',
'notificationType_new-chat',
'notificationType_group-invite',
];
2018-04-02 12:48:22 -04:00
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,
2018-04-02 12:48:22 -04:00
privilegedTypes: privilegedTypes,
}, next);
},
function (results) {
2018-04-02 12:48:22 -04:00
var notificationSettings = results.types.concat(results.privilegedTypes).map(function (type) {
return {
name: type,
label: '[[notifications:' + type + ']]',
};
});
res.render('admin/settings/user', {
notificationSettings: notificationSettings,
});
},
], next);
}