1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-07-20 14:15:22 +00:00

Can remove a friendship request

This commit is contained in:
2020-06-30 10:24:18 +02:00
parent baf568142d
commit 13f86fd8c1
4 changed files with 36 additions and 0 deletions

@@ -611,6 +611,15 @@ impl DeleteQuery {
self
}
pub fn cond_legacy_bool(mut self, key: &str, value: bool) -> DeleteQuery {
let value = match value {
true => 1,
false => 0
};
self.conditions.insert(key.to_string(), Value::from(value));
self
}
pub fn cond_user_id(mut self, key: &str, value: &UserID) -> DeleteQuery {
self.conditions.insert(key.to_string(), Value::from(value.id()));
self

@@ -70,6 +70,15 @@ pub fn send_request(user_id: &UserID, target_user: &UserID) -> ResultBoxError {
.insert_drop_result()
}
/// Remove a friendship request
pub fn remove_request(user_id: &UserID, target_user: &UserID) -> ResultBoxError {
database::DeleteQuery::new(FRIENDS_TABLE)
.cond_user_id("ID_personne", target_user)
.cond_user_id("ID_amis", user_id)
.cond_legacy_bool("actif", false)
.exec()
}
/// Check out whether a user has sent a request to another user
pub fn sent_request(user_id: &UserID, target_user: &UserID) -> ResultBoxError<bool> {
database::QueryInfo::new(FRIENDS_TABLE)