mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 08:25:16 +00:00
Can get current push notifications status for a token
This commit is contained in:
@ -69,4 +69,5 @@ pub mod res_check_password_token;
|
||||
pub mod removed_user_from_conv_message;
|
||||
pub mod user_is_writing_message_in_conversation;
|
||||
pub mod res_create_conversation_for_group;
|
||||
pub mod notification_settings_api;
|
||||
pub mod notification_settings_api;
|
||||
pub mod push_notifications_status_api;
|
29
src/api_data/push_notifications_status_api.rs
Normal file
29
src/api_data/push_notifications_status_api.rs
Normal file
@ -0,0 +1,29 @@
|
||||
//! # Push notification status API
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::data::user_token::PushNotificationToken;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct PushNotificationsStatusAPI {
|
||||
pub status: String,
|
||||
pub independent_push_token: Option<String>,
|
||||
}
|
||||
|
||||
impl PushNotificationsStatusAPI {
|
||||
pub fn new(t: &PushNotificationToken) -> Self {
|
||||
Self {
|
||||
status: match t {
|
||||
PushNotificationToken::UNDEFINED => "undefined",
|
||||
PushNotificationToken::NONE => "disabled",
|
||||
PushNotificationToken::INDEPENDENT(_) => "independent",
|
||||
PushNotificationToken::FIREBASE(_) => "firebase",
|
||||
}.to_string(),
|
||||
|
||||
independent_push_token: match t {
|
||||
PushNotificationToken::INDEPENDENT(i) => Some(i.to_string()),
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user