1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-02 02:06:27 +00:00
comunicapiv3/src/helpers/notifications_helper.rs

17 lines
522 B
Rust
Raw Normal View History

//! # 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)
}