File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,7 @@ export const createUser = async(req, res) => {
7070 username,
7171 email,
7272 password : hashedPassword ,
73- isOneline : true ,
74- pfp : "" , //pfp string url, save a temp one for now after creation
73+ isOneline : true , //got rid of pfp so it uses the default values
7574 description : "" , //description, empty for now (could default to "" in the schema)
7675 friendsList : [ ] ,
7776 friendRequest : [ ] ,
@@ -484,7 +483,7 @@ export const acceptFriendRequest = async(req, res) => {
484483export const rejectFriendRequest = async ( req , res ) => {
485484 try {
486485 const userId = req . params . id
487- const user = await User . findByid ( userId )
486+ const user = await User . findById ( userId )
488487
489488 const otherUser = req . body . friendId ;
490489 const rejectingUser = await User . findById ( otherUser ) ;
@@ -498,6 +497,10 @@ export const rejectFriendRequest = async(req, res) => {
498497 return ;
499498 }
500499
500+ if ( ! user . friendRequests . includes ( otherUser ) ) {
501+ return res . status ( 400 ) . json ( { message : "No such friend request exists" } ) ;
502+ }
503+
501504 user . friendRequests . pull ( rejectingUser . _id ) ;
502505 await user . save ( )
503506 res . status ( 200 ) . json ( { message : 'Friend request rejected!' } )
You can’t perform that action at this time.
0 commit comments