diff --git a/public/language/en-GB/email.json b/public/language/en-GB/email.json index e893709772..a55f4f1f52 100644 --- a/public/language/en-GB/email.json +++ b/public/language/en-GB/email.json @@ -44,5 +44,10 @@ "unsub.cta": "Click here to alter those settings", + "banned.subject": "You have been banned from %1", + "banned.text1": "The user %1 has been banned from %2.", + "banned.text2": "This ban will last until %1.", + "banned.text3": "This is the reason why you have been banned:", + "closing": "Thanks!" } \ No newline at end of file diff --git a/src/socket.io/user/ban.js b/src/socket.io/user/ban.js index cbc15d3270..191b98767e 100644 --- a/src/socket.io/user/ban.js +++ b/src/socket.io/user/ban.js @@ -3,10 +3,12 @@ var async = require('async'); var user = require('../../user'); +var meta = require('../../meta'); var websockets = require('../index'); var events = require('../../events'); var privileges = require('../../privileges'); var plugins = require('../../plugins'); +var emailer = require('../../emailer'); var translator = require('../../translator'); module.exports = function (SocketUser) { @@ -97,6 +99,22 @@ module.exports = function (SocketUser) { if (isAdmin) { return next(new Error('[[error:cant-ban-other-admins]]')); } + + user.getUserField(uid, 'username', next); + }, + function (username, next) { + var siteTitle = meta.config.title || 'NodeBB'; + var data = { + subject: '[[email:banned.subject, ' + siteTitle + ']]', + site_title: siteTitle, + username: username, + until: until ? new Date(until).toString() : false, + reason: reason, + }; + + emailer.send('banned', uid, data, next); + }, + function (next) { user.ban(uid, until, reason, next); }, function (next) { diff --git a/src/views/emails/banned.tpl b/src/views/emails/banned.tpl new file mode 100644 index 0000000000..2384fe1549 --- /dev/null +++ b/src/views/emails/banned.tpl @@ -0,0 +1,18 @@ +
+ [[email:banned.text1, {username}, {site_title}]] + + [[email:banned.text2, {until}]] + +
+ + ++ [[email:banned.text3]] +
+ ++ {reason} +
+ + + \ No newline at end of file