From 2f0a331f02a65ebc02650bc8f3e588437cb6555a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 19 Jul 2019 17:02:25 -0400 Subject: [PATCH] fix: don't return promise --- src/socket.io/groups.js | 3 ++- src/socket.io/topics/infinitescroll.js | 3 ++- src/socket.io/user/ban.js | 11 +++++------ test/socket.io.js | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js index a92fd4d5f5..505c79b04f 100644 --- a/src/socket.io/groups.js +++ b/src/socket.io/groups.js @@ -38,7 +38,8 @@ SocketGroups.join = function (socket, data, callback) { } if (!meta.config.allowPrivateGroups) { - return groups.join(data.groupName, socket.uid, callback); + groups.join(data.groupName, socket.uid, callback); + return; } async.parallel({ diff --git a/src/socket.io/topics/infinitescroll.js b/src/socket.io/topics/infinitescroll.js index 11523d79b5..9172b21719 100644 --- a/src/socket.io/topics/infinitescroll.js +++ b/src/socket.io/topics/infinitescroll.js @@ -93,7 +93,8 @@ module.exports = function (SocketTopics) { }; if (data.sort === 'unread') { params.cid = data.cid; - return topics.getUnreadTopics(params, callback); + topics.getUnreadTopics(params, callback); + return; } params.cids = data.cid; params.sort = data.sort; diff --git a/src/socket.io/user/ban.js b/src/socket.io/user/ban.js index d84c672442..ca70884000 100644 --- a/src/socket.io/user/ban.js +++ b/src/socket.io/user/ban.js @@ -130,13 +130,12 @@ module.exports = function (SocketUser) { db.setObjectField('uid:' + uid + ':ban:' + banData.timestamp, 'fromUid', callerUid, next); }, function (next) { - if (!reason) { - return translator.translate('[[user:info.banned-no-reason]]', function (translated) { - next(null, translated); - }); + if (reason) { + return next(null, reason); } - - next(null, reason); + translator.translate('[[user:info.banned-no-reason]]', function (translated) { + next(null, translated); + }); }, function (_reason, next) { websockets.in('uid_' + uid).emit('event:banned', { diff --git a/test/socket.io.js b/test/socket.io.js index 9bb2d53e43..6ad4885294 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -127,7 +127,7 @@ describe('socket.io', function () { it('should get more unread topics', function (done) { io.emit('topics.loadMoreSortedTopics', { after: 0, count: 10, direction: 1, sort: 'unread' }, function (err, result) { assert.ifError(err); - console.log(result); + assert(Array.isArray(result.topics)); done(); }); });