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" }
|
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" }
|
# 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" }
|
# 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" {
|
if sub.endpoint == "fcm" {
|
||||||
// Use Firebase Cloud Messaging
|
// Use Firebase Cloud Messaging
|
||||||
if let Some(client) = &fcm_client {
|
if let Some(client) = &fcm_client {
|
||||||
let PushNotification {
|
|
||||||
author,
|
|
||||||
icon,
|
|
||||||
image,
|
|
||||||
body,
|
|
||||||
tag: _,
|
|
||||||
timestamp: _,
|
|
||||||
url: _,
|
|
||||||
message: _,
|
|
||||||
} = &task.payload;
|
|
||||||
|
|
||||||
let message = fcm_v1::message::Message {
|
let message = fcm_v1::message::Message {
|
||||||
token: Some(sub.auth),
|
token: Some(sub.auth),
|
||||||
data: Some(HashMap::from([
|
data: Some(HashMap::from([(
|
||||||
(
|
"payload".to_owned(),
|
||||||
"author".to_owned(),
|
serde_json::Value::String(json!(&task.payload).to_string()),
|
||||||
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())),
|
|
||||||
])),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user