Skip to content

Commit

Permalink
Add: withdraw check into items.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kmc7468 committed Nov 29, 2024
1 parent 372ecab commit f58f645
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lottery/services/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ const getItemLeaderboardHandler = async (req, res) => {
leaderboardBase
.filter((user) => user.rank <= 20)
.map(async (user) => {
const userInfo = await userModel.findById(user.userId).lean();
const userInfo = await userModel
.findOne({ _id: user.userId, withdraw: false })
.lean();
if (!userInfo) {
logger.error(`Fail to find user ${user.userId}`);
return null;
}
return {
nickname: userInfo.nickname,
profileImageUrl: userInfo.profileImageUrl,
Expand All @@ -135,6 +141,10 @@ const getItemLeaderboardHandler = async (req, res) => {
};
})
);
if (leaderboard.includes(null))
return res
.status(500)
.json({ error: "Items/leaderboard : internal server error" });

const userId = isLogin(req) ? getLoginInfo(req).oid : null;
const user = leaderboardBase.find(
Expand Down

0 comments on commit f58f645

Please sign in to comment.