1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 07:19:22 +00:00

Give full independent push service URL

This commit is contained in:
Pierre HUBERT 2021-04-12 17:03:42 +02:00
parent 5d63cd8945
commit 9c1675235c
2 changed files with 6 additions and 4 deletions

View File

@ -35,7 +35,7 @@ independent-push-service:
control-token: BADTOKENTOCHANGE control-token: BADTOKENTOCHANGE
# Public access URL pattern (for clients access) {TOKEN_URL} will be replaced by client token # Public access URL pattern (for clients access) {TOKEN_URL} will be replaced by client token
public-url: http://localhost:4500/ws/{TOKEN_URL} public-url: ws://localhost:4500/ws/{TOKEN_URL}
# Database configuration # Database configuration

View File

@ -2,12 +2,13 @@
use serde::Serialize; use serde::Serialize;
use crate::data::config::conf;
use crate::data::user_token::PushNotificationToken; use crate::data::user_token::PushNotificationToken;
#[derive(Serialize)] #[derive(Serialize)]
pub struct PushNotificationsStatusAPI { pub struct PushNotificationsStatusAPI {
pub status: String, pub status: String,
pub independent_push_token: Option<String>, pub independent_push_url: Option<String>,
} }
impl PushNotificationsStatusAPI { impl PushNotificationsStatusAPI {
@ -20,8 +21,9 @@ impl PushNotificationsStatusAPI {
PushNotificationToken::FIREBASE(_) => "firebase", PushNotificationToken::FIREBASE(_) => "firebase",
}.to_string(), }.to_string(),
independent_push_token: match t { independent_push_url: match (t, &conf().independent_push_service) {
PushNotificationToken::INDEPENDENT(i) => Some(i.to_string()), (PushNotificationToken::INDEPENDENT(i), Some(conf)) =>
Some(conf.public_url.replace("{TOKEN_URL}", i)),
_ => None, _ => None,
}, },
} }