send the banned user an email with reason + time limit if applies

v1.18.x
psychobunny 8 years ago
parent 2a405ad439
commit 480352c650

@ -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!"
}

@ -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) {

@ -0,0 +1,18 @@
<p>
[[email:banned.text1, {username}, {site_title}]]
<!-- IF until -->
[[email:banned.text2, {until}]]
<!-- ENDIF until -->
</p>
<!-- IF reason -->
<p>
[[email:banned.text3]]
</p>
<p>
{reason}
</p>
<!-- ENDIF reason -->
<!-- IMPORT emails/partials/footer.tpl -->
Loading…
Cancel
Save