Skip to content

Commit eee48c4

Browse files
committed
fix: update checkIfUserBlocked to directly query by email and simplify response structure
1 parent b517a98 commit eee48c4

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

controllers/blockedUser.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,15 @@ exports.checkIfUserBlocked = async (req, res) => {
1010
});
1111
}
1212

13-
const doc = await BlockedUsersFromApp.findOne();
13+
const doc = await BlockedUsersFromApp.findOne({email: email});
1414

1515
if (!doc) {
1616
return res.json({ isBlocked: false });
1717
}
1818

19-
const user = doc.blockedUsers.find((u) => u.email === email.toLowerCase());
20-
21-
if (!user) {
22-
return res.json({ isBlocked: false });
23-
}
24-
2519
return res.json({
26-
isBlocked: user.isPermanent,
27-
reportCount: user.count,
20+
isBlocked: doc.isPermanent,
21+
reportCount: doc.count,
2822
});
2923
} catch (err) {
3024
console.error("CHECK BLOCK ERROR:", err);

0 commit comments

Comments
 (0)