mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-19 05:55:34 +09:00
fix(push): keep notification images within the web push budget (#3043)
This commit is contained in:
1 parent
071263188a
commit
2808edf6d0
1 file changed
+2
-5
@@ -46,7 +46,7 @@ pub fn web_push_message(job: &MessageJob, target_user_id: &str, badge_count: u32
|
|||||||
} else {
|
} else {
|
||||||
Value::String(job.guild_id.clone())
|
Value::String(job.guild_id.clone())
|
||||||
};
|
};
|
||||||
let mut data = json!({
|
let data = json!({
|
||||||
"channel_id": job.channel_id,
|
"channel_id": job.channel_id,
|
||||||
"author_avatar_url": fields.icon,
|
"author_avatar_url": fields.icon,
|
||||||
"message_id": job.message_id,
|
"message_id": job.message_id,
|
||||||
@@ -57,8 +57,7 @@ pub fn web_push_message(job: &MessageJob, target_user_id: &str, badge_count: u32
|
|||||||
"target_user_id": target_user_id,
|
"target_user_id": target_user_id,
|
||||||
"has_media": image_url.is_some(),
|
"has_media": image_url.is_some(),
|
||||||
});
|
});
|
||||||
merge_image_fields(&mut data, image_url);
|
let notification = json!({
|
||||||
let mut notification = json!({
|
|
||||||
"title": fields.title,
|
"title": fields.title,
|
||||||
"body": fields.body,
|
"body": fields.body,
|
||||||
"icon": fields.icon,
|
"icon": fields.icon,
|
||||||
@@ -68,7 +67,6 @@ pub fn web_push_message(job: &MessageJob, target_user_id: &str, badge_count: u32
|
|||||||
"app_badge": badge_count.to_string(),
|
"app_badge": badge_count.to_string(),
|
||||||
"data": data,
|
"data": data,
|
||||||
});
|
});
|
||||||
merge_image_fields(&mut notification, image_url);
|
|
||||||
let mut envelope = json!({
|
let mut envelope = json!({
|
||||||
"web_push": WEB_PUSH_MARKER,
|
"web_push": WEB_PUSH_MARKER,
|
||||||
"notification": notification,
|
"notification": notification,
|
||||||
@@ -582,7 +580,6 @@ fn merge_image_fields(target: &mut Value, image_url: Option<&str>) {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
object.insert("image_url".to_owned(), image_url.into());
|
object.insert("image_url".to_owned(), image_url.into());
|
||||||
object.insert("image".to_owned(), image_url.into());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn non_empty(value: &Value) -> Option<&str> {
|
fn non_empty(value: &Value) -> Option<&str> {
|
||||||
|
|||||||
Reference in new issue
Block a user