mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 21:39:21 +00:00
Can delete all the friends of a user
This commit is contained in:
parent
6518ff5be8
commit
f7a2623951
@ -330,6 +330,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError {
|
||||
// Delete all the notifications related with the user
|
||||
notifications_helper::delete_all_related_with_user(user_id)?;
|
||||
|
||||
// Delete all user friends, including friendship requests
|
||||
friends_helper::delete_all_user(user_id)?;
|
||||
|
||||
// TODO : continue work here
|
||||
|
||||
Ok(())
|
||||
|
@ -247,6 +247,17 @@ pub fn count_requests(user_id: &UserID) -> ResultBoxError<u64> {
|
||||
.map(|r| r as u64)
|
||||
}
|
||||
|
||||
/// Delete all the friends of a given user
|
||||
pub fn delete_all_user(user_id: &UserID) -> ResultBoxError {
|
||||
database::DeleteQuery::new(FRIENDS_TABLE)
|
||||
.cond_user_id("ID_personne", user_id)
|
||||
.exec()?;
|
||||
|
||||
database::DeleteQuery::new(FRIENDS_TABLE)
|
||||
.cond_user_id("ID_amis", user_id)
|
||||
.exec()
|
||||
}
|
||||
|
||||
/// Turn a database entry into a Friend structure
|
||||
fn db_to_friend(row: &database::RowResult) -> ResultBoxError<Friend> {
|
||||
Ok(Friend {
|
||||
|
Loading…
Reference in New Issue
Block a user