mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-09 00:52:49 +00:00
Add the method /notifications/count_all_news
This commit is contained in:
src
api_data
controllers
helpers
@ -38,4 +38,5 @@ pub mod comment_api;
|
||||
pub mod res_create_post;
|
||||
pub mod posts_targets_api;
|
||||
pub mod res_create_comment;
|
||||
pub mod res_number_unread_notifications;
|
||||
pub mod res_number_unread_notifications;
|
||||
pub mod res_count_all_unreads;
|
30
src/api_data/res_count_all_unreads.rs
Normal file
30
src/api_data/res_count_all_unreads.rs
Normal file
@ -0,0 +1,30 @@
|
||||
//! # Count unread notifications & conversation
|
||||
//!
|
||||
//! Optionally includes friendship requests too
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct CountFriendsRequests {
|
||||
friends_requests: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ResCountAllUnread {
|
||||
notifications: u64,
|
||||
conversations: u64,
|
||||
|
||||
#[serde(flatten)]
|
||||
friends: Option<CountFriendsRequests>,
|
||||
}
|
||||
|
||||
impl ResCountAllUnread {
|
||||
pub fn new(notifications: u64, conversations: u64, friends_requests: Option<u64>) -> ResCountAllUnread {
|
||||
ResCountAllUnread {
|
||||
notifications,
|
||||
conversations,
|
||||
friends: friends_requests.map(|n| CountFriendsRequests { friends_requests: n }),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user