mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-02-23 01:01:16 +00:00
29 lines
852 B
Rust
29 lines
852 B
Rust
|
//! # 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,
|
||
|
},
|
||
|
}
|
||
|
}
|
||
|
}
|