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

65 lines
1.4 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');
2018-04-22 09:10:02 -04:00
var notifications = require('../../notifications');
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) {
async.waterfall([
function (next) {
2018-04-22 09:10:02 -04:00
notifications.getAllNotificationTypes(next);
},
2018-04-22 09:10:02 -04:00
function (notificationTypes) {
var notificationSettings = notificationTypes.map(function (type) {
return {
name: type,
label: '[[notifications:' + type + ']]',
};
});
res.render('admin/settings/user', {
notificationSettings: notificationSettings,
});
},
], next);
}