diff options
Diffstat (limited to 'src/controller')
-rw-r--r-- | src/controller/friend.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/controller/friend.ts b/src/controller/friend.ts index 5d76350..4690f39 100644 --- a/src/controller/friend.ts +++ b/src/controller/friend.ts @@ -87,9 +87,11 @@ const addFriend = async (req: Request, res: Response) => { const removeFriend = async (req: Request, res: Response) => { try { + if (req.body.friendId === undefined || req.body.friendId === null || !Number.isInteger(req.body.friendId)) { + res.status(400).json({ message: "Invalid Friend ID" }); // @ts-ignore - if (req.userId == req.body.friendId) { - res.status(400).json({ message: "Attempted to unfriend self" }); + } else if (req.userId == req.body.friendId) { + res.status(400).json({message: "Attempted to unfriend self"}); } else { // @ts-ignore const { count } = await unfriend(req.userId, req.body.friendId) |