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

Can count the number of unread notifications

This commit is contained in:
2020-07-10 12:55:50 +02:00
parent 6b0363935e
commit 32aa7e7d1e
8 changed files with 58 additions and 3 deletions

View File

@ -13,4 +13,5 @@ pub mod conversations_helper;
pub mod virtual_directory_helper;
pub mod movies_helper;
pub mod survey_helper;
pub mod comments_helper;
pub mod comments_helper;
pub mod notifications_helper;

View File

@ -0,0 +1,17 @@
//! # Notifications helper
//!
//! @author Pierre Hubert
use crate::constants::database_tables_names::NOTIFICATIONS_TABLE;
use crate::data::error::ResultBoxError;
use crate::data::user::UserID;
use crate::helpers::database;
/// Count the number of unread notifications
pub fn count_unread(user_id: &UserID) -> ResultBoxError<u64> {
database::QueryInfo::new(NOTIFICATIONS_TABLE)
.cond_user_id("dest_user_id", user_id)
.cond_legacy_bool("seen", false)
.exec_count()
.map(|c| c as u64)
}