Node.js based forum software built for the modern web
closes #3788
barisusakli9bc43ba5e1e8
diff --git a/src/messaging.js b/src/messaging.jsindex 7609ad24f9..0631de61f8 100644--- a/src/messaging.js+++ b/src/messaging.js@@ -374,12 +374,8 @@ var db = require('./database'),};Messaging.canMessage = function(fromUid, toUid, callback) {- if (parseInt(meta.config.disableChat) === 1) {- return callback(new Error('[[error:chat-disabled]]'));- } else if (toUid === fromUid) {- return callback(new Error('[[error:cant-chat-with-yourself]]'));- } else if (!fromUid) {- return callback(new Error('[[error:not-logged-in]]'));+ if (parseInt(meta.config.disableChat) === 1 || !fromUid || toUid === fromUid) {+ return callback(null, false);}async.waterfall([@@ -388,17 +384,17 @@ var db = require('./database'),},function (exists, next) {if (!exists) {- return next(new Error('[[error:no-user]]'));+ return callback(null, false);}user.getUserFields(fromUid, ['banned', 'email:confirmed'], next);},function (userData, next) {if (parseInt(userData.banned, 10) === 1) {- return next(new Error('[[error:user-banned]]'));+ return callback(null, false);}if (parseInt(meta.config.requireEmailConfirmation, 10) === 1 && parseInt(userData['email:confirmed'], 10) !== 1) {- return next(new Error('[[error:email-not-confirmed-chat]]'));+ return callback(null, false);}user.getSettings(toUid, next);diff --git a/src/routes/index.js b/src/routes/index.jsindex 57a8c8134a..8d011f7f5a 100644--- a/src/routes/index.js+++ b/src/routes/index.js@@ -175,7 +175,7 @@ function handle404(app, middleware) {}function handleErrors(app, middleware) {- app.use(function(err, req, res) {+ app.use(function(err, req, res, next) {if (err.code === 'EBADCSRFTOKEN') {winston.error(req.path + '\n', err.message);return res.sendStatus(403);@@ -190,7 +190,7 @@ function handleErrors(app, middleware) {res.status(err.status || 500);if (res.locals.isAPI) {- return res.json({path: req.path, error: err.message});+ res.json({path: req.path, error: err.message});} else {middleware.buildHeader(req, res, function() {res.render('500', {path: req.path, error: err.message});diff --git a/src/views/500-embed.tpl b/src/views/500-embed.tplnew file mode 100644index 0000000000..537cbac136--- /dev/null+++ b/src/views/500-embed.tpl@@ -0,0 +1,9 @@+<script type="text/tpl" data-template="500">+<div class="alert alert-danger">+ <strong>[[global:500.title]]</strong>+ <p>[[global:500.message]]</p>+ <p>{path}</p>+ <!-- IF error --><p>{error}</p><!-- ENDIF error -->++</div>+</script>\ No newline at end of filediff --git a/src/views/500.tpl b/src/views/500.tplindex 537cbac136..3abb9e8e27 100644--- a/src/views/500.tpl+++ b/src/views/500.tpl@@ -1,9 +1,6 @@-<script type="text/tpl" data-template="500"><div class="alert alert-danger"><strong>[[global:500.title]]</strong><p>[[global:500.message]]</p><p>{path}</p><!-- IF error --><p>{error}</p><!-- ENDIF error -->-</div>-</script>\ No newline at end of file