From 2faaf5b35fa5a9cd9ec7b576111084a41d0a27f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 27 Mar 2018 17:01:51 -0400 Subject: [PATCH] closes https://github.com/julianlam/nodebb-plugin-mentions/issues/99 --- install/data/defaults.json | 3 +- src/controllers/admin/settings.js | 70 ++++++++++++++++++++++------- src/views/admin/settings/user.tpl | 73 +++---------------------------- 3 files changed, 61 insertions(+), 85 deletions(-) diff --git a/install/data/defaults.json b/install/data/defaults.json index 36ede59795..cecf4d8a38 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -45,5 +45,6 @@ "notificationType_new-reply": "notification", "notificationType_follow": "notification", "notificationType_new-chat": "notification", - "notificationType_group-invite": "notification" + "notificationType_group-invite": "notification", + "notificationType_mention": "notification" } diff --git a/src/controllers/admin/settings.js b/src/controllers/admin/settings.js index 860de1290d..81e902d0fd 100644 --- a/src/controllers/admin/settings.js +++ b/src/controllers/admin/settings.js @@ -4,6 +4,7 @@ var async = require('async'); var meta = require('../../meta'); var emailer = require('../../emailer'); +var plugins = require('../../plugins'); var settingsController = module.exports; @@ -14,7 +15,9 @@ settingsController.get = function (req, res, next) { case 'email': renderEmail(req, res, next); break; - + case 'user': + renderUser(req, res, next); + break; default: res.render('admin/settings/' + term); } @@ -22,20 +25,53 @@ settingsController.get = function (req, res, next) { function renderEmail(req, res, next) { - async.parallel({ - emails: async.apply(emailer.getTemplates, meta.config), - services: emailer.listServices, - }, function (err, results) { - if (err) { - return next(err); - } - - 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, - }); - }); + 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', + ]; + + async.waterfall([ + function (next) { + plugins.fireHook('filter:user.notificationTypes', { + userData: {}, + types: types, + privilegedTypes: [], + }, next); + }, + function (results) { + var notificationSettings = results.types.map(function modifyType(type) { + return { + name: type, + label: '[[notifications:' + type + ']]', + }; + }); + res.render('admin/settings/user', { + notificationSettings: notificationSettings, + }); + }, + ], next); } diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tpl index ff4b8269b4..5b1a003068 100644 --- a/src/views/admin/settings/user.tpl +++ b/src/views/admin/settings/user.tpl @@ -292,77 +292,14 @@ + +
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- +
- @@ -370,6 +307,8 @@
+ +