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:
@ -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;
|
17
src/helpers/notifications_helper.rs
Normal file
17
src/helpers/notifications_helper.rs
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user