diff --git a/src/groups/leave.js b/src/groups/leave.js index ca19d08950..b7ca0c9b7c 100644 --- a/src/groups/leave.js +++ b/src/groups/leave.js @@ -14,12 +14,9 @@ module.exports = function (Groups) { groupNames = [groupNames]; } - const [isMembers, exists] = await Promise.all([ - Groups.isMemberOfGroups(uid, groupNames), - Groups.exists(groupNames), - ]); + const isMembers = await Groups.isMemberOfGroups(uid, groupNames); - const groupsToLeave = groupNames.filter((groupName, index) => isMembers[index] && exists[index]); + const groupsToLeave = groupNames.filter((groupName, index) => isMembers[index]); if (!groupsToLeave.length) { return; } diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js index 32bf48c534..3ad98a809f 100644 --- a/src/plugins/hooks.js +++ b/src/plugins/hooks.js @@ -132,17 +132,16 @@ module.exports = function (Plugins) { if (!Array.isArray(hookList) || !hookList.length) { return; } - await async.each(hookList, function (hookObj, next) { + for (const hookObj of hookList) { if (typeof hookObj.method !== 'function') { if (global.env === 'development') { winston.warn('[plugins] Expected method for hook \'' + hook + '\' in plugin \'' + hookObj.id + '\' not found, skipping.'); } - return next(); + } else { + /* eslint-disable no-await-in-loop */ + await hookObj.method(params); } - - hookObj.method(params); - next(); - }); + } } async function fireStaticHook(hook, hookList, params) { diff --git a/src/rewards/index.js b/src/rewards/index.js index 825602a8e5..7144c7c4ae 100644 --- a/src/rewards/index.js +++ b/src/rewards/index.js @@ -70,10 +70,11 @@ async function checkCondition(reward, method) { async function giveRewards(uid, rewards) { const rewardData = await getRewardsByRewardData(rewards); - await Promise.all(rewards.map(async function (reward) { - plugins.fireHook('action:rewards.award:' + reward.rid, { uid: uid, reward: rewardData[rewards.indexOf(reward)] }); - await db.sortedSetIncrBy('uid:' + uid + ':rewards', 1, reward.id); - })); + for (let i = 0; i < rewards.length; i++) { + /* eslint-disable no-await-in-loop */ + await plugins.fireHook('action:rewards.award:' + rewards[i].rid, { uid: uid, reward: rewardData[i] }); + await db.sortedSetIncrBy('uid:' + uid + ':rewards', 1, rewards[i].id); + } } require('../promisify')(rewards);