mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 21:47:02 +00:00
chore(fcm): just send the whole payload as a json string
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user