Skip to content

Commit

Permalink
remove from device token
Browse files Browse the repository at this point in the history
  • Loading branch information
lassemand committed Sep 27, 2024
1 parent f4a06be commit aeb97c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion notification-server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion notification-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Concordium AG [email protected]"]
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

Expand Down
12 changes: 10 additions & 2 deletions notification-server/src/bin/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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<Arc<AppState>>,
Json(device_token): Json<String>,
Json(device_token): Json<DeviceInput>,
) -> 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) => {
Expand Down

0 comments on commit aeb97c4

Please sign in to comment.