fix: Ice Cubes push notifications
Co-authored-by: Eana Hufwe <eana@1a23.com>
This commit is contained in:
parent
3a62097ec3
commit
8fca35ca06
1 changed files with 23 additions and 2 deletions
|
@ -8,7 +8,7 @@ use once_cell::sync::OnceCell;
|
||||||
use sea_orm::{prelude::*, DbErr};
|
use sea_orm::{prelude::*, DbErr};
|
||||||
use web_push::{
|
use web_push::{
|
||||||
ContentEncoding, IsahcWebPushClient, SubscriptionInfo, SubscriptionKeys, VapidSignatureBuilder,
|
ContentEncoding, IsahcWebPushClient, SubscriptionInfo, SubscriptionKeys, VapidSignatureBuilder,
|
||||||
WebPushClient, WebPushError, WebPushMessageBuilder,
|
WebPushClient, WebPushError, WebPushMessageBuilder, WebPushPayload,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
|
@ -298,7 +298,28 @@ pub async fn send_push_notification(
|
||||||
handle_web_push_failure(db, err, &subscription.id, "failed to build a payload").await?;
|
handle_web_push_failure(db, err, &subscription.id, "failed to build a payload").await?;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Err(err) = get_client()?.send(message.unwrap()).await {
|
|
||||||
|
// Ice Cubes cannot process ";rs=4096" at at the end of Encryption header
|
||||||
|
let mut message = message.unwrap();
|
||||||
|
|
||||||
|
if let Some(payload) = message.payload {
|
||||||
|
let crypto_headers: Vec<(&str, String)> = payload
|
||||||
|
.crypto_headers
|
||||||
|
.into_iter()
|
||||||
|
.map(|(key, val)| match key {
|
||||||
|
"Encryption" => (key, val.replace(";rs=4096", "")),
|
||||||
|
_ => (key, val),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
message.payload = Some(WebPushPayload {
|
||||||
|
content: payload.content,
|
||||||
|
content_encoding: payload.content_encoding,
|
||||||
|
crypto_headers,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(err) = get_client()?.send(message).await {
|
||||||
handle_web_push_failure(db, err, &subscription.id, "failed to send").await?;
|
handle_web_push_failure(db, err, &subscription.id, "failed to send").await?;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue