chore(fcm): just send the whole payload as a json string

This commit is contained in:
Paul Makles
2024-08-30 15:32:39 +01:00
parent d8acaa1107
commit 31262315e7
2 changed files with 6 additions and 27 deletions

View File

@@ -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

View File

@@ -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()
};