mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-02 02:06:27 +00:00
17 lines
522 B
Rust
17 lines
522 B
Rust
|
//! # 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)
|
||
|
}
|