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');
|
2019-10-28 14:36:14 -04:00
|
|
|
const groups = require('../../groups');
|
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);
|
2019-10-28 14:36:14 -04:00
|
|
|
} else if (term === 'post') {
|
|
|
|
|
await renderPost(req, res, next);
|
2019-08-14 22:48:57 -04:00
|
|
|
} 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) {
|
2019-09-18 17:52:07 -04:00
|
|
|
const emails = await emailer.getTemplates(meta.config);
|
|
|
|
|
|
2019-08-14 22:48:57 -04:00
|
|
|
res.render('admin/settings/email', {
|
|
|
|
|
emails: emails,
|
2019-09-18 17:52:07 -04:00
|
|
|
sendable: emails.filter(e => !e.path.includes('_plaintext') && !e.path.includes('partials')),
|
|
|
|
|
services: emailer.listServices(),
|
2019-08-14 22:48:57 -04:00
|
|
|
});
|
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
|
|
|
}
|
2019-10-28 14:36:14 -04:00
|
|
|
|
|
|
|
|
async function renderPost(req, res) {
|
|
|
|
|
const groupData = await groups.getNonPrivilegeGroups('groups:createtime', 0, -1);
|
|
|
|
|
res.render('admin/settings/post', {
|
|
|
|
|
groupsExemptFromPostQueue: groupData,
|
|
|
|
|
});
|
|
|
|
|
}
|