1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Add the method /notifications/count_all_news

This commit is contained in:
2020-07-10 13:31:40 +02:00
parent 32aa7e7d1e
commit 1eac896291
5 changed files with 57 additions and 2 deletions

View File

@ -238,6 +238,15 @@ pub fn get_status(user_id: &UserID, friend_id: &UserID) -> ResultBoxError<Friend
Ok(status)
}
/// Count the number of friendship requests of a user
pub fn count_requests(user_id: &UserID) -> ResultBoxError<u64> {
database::QueryInfo::new(FRIENDS_TABLE)
.cond_user_id("ID_personne", user_id)
.cond_legacy_bool("actif", false)
.exec_count()
.map(|r| r as u64)
}
/// Turn a database entry into a Friend structure
fn db_to_friend(row: &database::RowResult) -> ResultBoxError<Friend> {
Ok(Friend {