2015-09-17 16:25:15 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
2019-08-14 22:48:57 -04:00
|
|
|
const meta = require('../../meta');
|
|
|
|
|
const emailer = require('../../emailer');
|
|
|
|
|
const notifications = require('../../notifications');
|
2017-08-30 14:26:41 -06:00
|
|
|
|
2019-08-14 22:48:57 -04:00
|
|
|
const settingsController = module.exports;
|
2016-10-31 13:52:26 +03:00
|
|
|
|
2019-08-14 22:48:57 -04:00
|
|
|
settingsController.get = async function (req, res, next) {
|
|
|
|
|
const term = req.params.term ? req.params.term : 'general';
|
2015-09-17 16:25:15 -04:00
|
|
|
|
2019-08-14 22:48:57 -04:00
|
|
|
if (term === 'email') {
|
|
|
|
|
await renderEmail(req, res, next);
|
|
|
|
|
} else if (term === 'user') {
|
|
|
|
|
await renderUser(req, res, next);
|
|
|
|
|
} else {
|
2017-02-18 02:38:03 -07:00
|
|
|
res.render('admin/settings/' + term);
|
2015-09-21 17:17:23 -04:00
|
|
|
}
|
2015-09-17 16:25:15 -04:00
|
|
|
};
|
|
|
|
|
|
2015-09-21 17:17:23 -04:00
|
|
|
|
2019-08-14 22:48:57 -04:00
|
|
|
async function renderEmail(req, res) {
|
|
|
|
|
const [emails, services] = await Promise.all([
|
|
|
|
|
emailer.getTemplates(meta.config),
|
|
|
|
|
emailer.listServices(),
|
|
|
|
|
]);
|
|
|
|
|
res.render('admin/settings/email', {
|
|
|
|
|
emails: emails,
|
|
|
|
|
sendable: emails.filter(function (email) {
|
|
|
|
|
return !email.path.includes('_plaintext') && !email.path.includes('partials');
|
|
|
|
|
}),
|
|
|
|
|
services: services,
|
|
|
|
|
});
|
2018-03-27 17:01:51 -04:00
|
|
|
}
|
|
|
|
|
|
2019-08-14 22:48:57 -04:00
|
|
|
async function renderUser(req, res) {
|
|
|
|
|
const notificationTypes = await notifications.getAllNotificationTypes();
|
|
|
|
|
const notificationSettings = notificationTypes.map(function (type) {
|
|
|
|
|
return {
|
|
|
|
|
name: type,
|
|
|
|
|
label: '[[notifications:' + type + ']]',
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
res.render('admin/settings/user', {
|
|
|
|
|
notificationSettings: notificationSettings,
|
|
|
|
|
});
|
2015-09-21 17:17:23 -04:00
|
|
|
}
|