diff --git a/notification-server/Cargo.lock b/notification-server/Cargo.lock index 535d4725..5f74ea61 100644 --- a/notification-server/Cargo.lock +++ b/notification-server/Cargo.lock @@ -2101,7 +2101,7 @@ dependencies = [ [[package]] name = "notification-server" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", diff --git a/notification-server/Cargo.toml b/notification-server/Cargo.toml index 8482b07a..2858ef3f 100644 --- a/notification-server/Cargo.toml +++ b/notification-server/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Concordium AG developers@concordium.com"] edition = "2021" name = "notification-server" -version = "0.3.5" +version = "0.3.6" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/notification-server/src/bin/api.rs b/notification-server/src/bin/api.rs index c75ef59b..154ad07d 100644 --- a/notification-server/src/bin/api.rs +++ b/notification-server/src/bin/api.rs @@ -24,6 +24,7 @@ use notification_server::{ }; use serde_json::json; use std::{collections::HashSet, path::PathBuf, str::FromStr, sync::Arc, time::Duration}; +use serde::{Deserialize, Serialize}; use tokio_postgres::Config; use tracing::{error, info}; @@ -245,12 +246,19 @@ async fn process_device_subscription( Ok("Subscribed accounts to device".to_string()) } + + +#[derive(Debug, Serialize, Deserialize)] +pub struct DeviceInput { + pub device_token: String, +} + async fn unsubscribe( State(state): State>, - Json(device_token): Json, + Json(device_token): Json, ) -> impl IntoResponse { info!("Unsubscribing device tokens"); - match state.db_connection.remove_subscription(device_token.as_str()).await { + match state.db_connection.remove_subscription(device_token.device_token.as_str()).await { Ok(0) => (StatusCode::NOT_FOUND, Json(provide_error_message("Device token not found".to_string()))), Ok(_) => (StatusCode::OK, Json(provide_message("Device token removed".to_string()))), Err(err) => {