mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 17:05:16 +00:00
Can respond to a friendship request
This commit is contained in:
@ -89,6 +89,28 @@ pub fn sent_request(user_id: &UserID, target_user: &UserID) -> ResultBoxError<bo
|
||||
.map(|f| f > 0)
|
||||
}
|
||||
|
||||
/// Respond to a friendship request
|
||||
pub fn respond_request(user_id: &UserID, friend_id: &UserID, accept: bool) -> ResultBoxError {
|
||||
// Delete the request
|
||||
remove_request(friend_id, user_id)?;
|
||||
|
||||
if accept {
|
||||
database::InsertQuery::new(FRIENDS_TABLE)
|
||||
.add_user_id("ID_personne", user_id)
|
||||
.add_user_id("ID_amis", friend_id)
|
||||
.add_legacy_bool("actif", true)
|
||||
.insert_drop_result()?;
|
||||
|
||||
database::InsertQuery::new(FRIENDS_TABLE)
|
||||
.add_user_id("ID_personne", friend_id)
|
||||
.add_user_id("ID_amis", user_id)
|
||||
.add_legacy_bool("actif", true)
|
||||
.insert_drop_result()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check out whether two users are friend or not
|
||||
pub fn are_friend(user_one: &UserID, user_two: &UserID) -> ResultBoxError<bool> {
|
||||
Ok(database::count(QueryInfo::new(FRIENDS_TABLE)
|
||||
|
Reference in New Issue
Block a user