From 31262315e7be54cc643436fc783f93c29dd38a15 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Fri, 30 Aug 2024 15:32:39 +0100 Subject: [PATCH] chore(fcm): just send the whole payload as a json string --- Cargo.toml | 2 ++ crates/core/database/src/tasks/web_push.rs | 31 +++------------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 61f6fa51..9004c46c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,5 @@ redis22 = { package = "redis", version = "0.22.3", git = "https://github.com/rev redis23 = { package = "redis", version = "0.23.1", git = "https://github.com/revoltchat/redis-rs", rev = "f8ca28ab85da59d2ccde526b4d2fb390eff5a5f9" } # authifier = { package = "authifier", version = "1.0.8", path = "../authifier/crates/authifier" } # rocket_authifier = { package = "rocket_authifier", version = "1.0.8", path = "../authifier/crates/rocket_authifier" } +[profile.release] +debug = false diff --git a/crates/core/database/src/tasks/web_push.rs b/crates/core/database/src/tasks/web_push.rs index 683de189..97588a6d 100644 --- a/crates/core/database/src/tasks/web_push.rs +++ b/crates/core/database/src/tasks/web_push.rs @@ -95,35 +95,12 @@ pub async fn worker(db: Database) { if sub.endpoint == "fcm" { // Use Firebase Cloud Messaging if let Some(client) = &fcm_client { - let PushNotification { - author, - icon, - image, - body, - tag: _, - timestamp: _, - url: _, - message: _, - } = &task.payload; - let message = fcm_v1::message::Message { token: Some(sub.auth), - data: Some(HashMap::from([ - ( - "author".to_owned(), - serde_json::Value::String(author.clone()), - ), - ("icon".to_owned(), serde_json::Value::String(icon.clone())), - ( - "image".to_owned(), - if let Some(image) = image { - serde_json::Value::String(image.clone()) - } else { - serde_json::Value::Null - }, - ), - ("body".to_owned(), serde_json::Value::String(body.clone())), - ])), + data: Some(HashMap::from([( + "payload".to_owned(), + serde_json::Value::String(json!(&task.payload).to_string()), + )])), ..Default::default() };