Skip to content

Commit

Permalink
Send error if user tries to befriend himself
Browse files Browse the repository at this point in the history
  • Loading branch information
myOmikron committed Apr 29, 2023
1 parent d772c7f commit cc0ec6b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/server/handler/friends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ pub async fn create_friend_request(

let mut tx = db.start_transaction().await?;

// Check if target is self
if uuid == req.uuid {
return Err(ApiError::InvalidUuid)?;
}

// Check if target exists
let target = query!(&mut tx, Account)
.condition(Account::F.uuid.equals(req.uuid.as_bytes().as_slice()))
Expand Down

0 comments on commit cc0ec6b

Please sign in to comment.