fix(push): keep read-state clears alive as long as the alert (#2919)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-24 01:26:18 +02:00
1 parent bd6ca7290e
commit ea9f83a443
6 files changed
+91 -6

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ const FALLBACK_TITLE: &str = "Fluxer";
const APNS_CATEGORY: &str = "FLUXER_MESSAGE";
const APNS_SOUND: &str = "default";
const APNS_ALERT_EXPIRATION_SECONDS: i64 = 86_400;
const APNS_BACKGROUND_EXPIRATION_SECONDS: i64 = 3_600;
const APNS_BACKGROUND_EXPIRATION_SECONDS: i64 = 86_400;
const APNS_COLLAPSE_ID_MAX_BYTES: usize = 64;
const SHRUNK_BODY_MAX_BYTES: usize = 40;
const MINIMAL_TITLE_MAX_BYTES: usize = 120;
@@ -168,7 +168,7 @@ fn fcm_clear_message(device_token: &str, envelope: &Value) -> Value {
"data": data,
"android": {
"priority": "NORMAL",
"ttl": "3600s",
"ttl": "86400s",
"collapse_key": format!("clear:{tag}"),
},
"fcm_options": {"analytics_label": CLEAR_TYPE},
+1 -1
View File
@@ -27,7 +27,7 @@ const MAX_TRANSIENT_RETRIES: u32 = 2;
const BASE_RETRY_DELAY_MS: u64 = 200;
const MAX_RETRY_DELAY_MS: u64 = 2_000;
const ALERT_TTL_SECONDS: &str = "86400";
const CLEAR_TTL_SECONDS: &str = "3600";
const CLEAR_TTL_SECONDS: &str = "86400";
const RING_TTL_SECONDS: &str = "0";
const TTL_HEADER: &str = "TTL";
const URGENCY_HEADER: &str = "Urgency";
+1 -1
View File
@@ -6,7 +6,7 @@ use serde_json::{Value, json};
pub const FORMAT_VERSION: u64 = 1;
pub const ALERT_TTL_CAP_SECONDS: i64 = 86_400;
pub const BACKGROUND_TTL_CAP_SECONDS: i64 = 3_600;
pub const BACKGROUND_TTL_CAP_SECONDS: i64 = 86_400;
pub const APNS_BODY_MAX_BYTES: usize = 4_096;
pub const FCM_DATA_MAX_BYTES: usize = 4_096;
+23
View File
@@ -539,6 +539,29 @@ mod tests {
assert_eq!(digest(""), "-");
}
#[test]
fn a_clear_survives_a_device_that_is_offline_for_a_day() {
assert_eq!(
Urgency::Background.ttl_cap_seconds(),
Urgency::Alert.ttl_cap_seconds(),
"a clear must outlive the alert it removes"
);
}
#[test]
fn a_clear_stays_silent_on_the_apns_leg() {
let body = envelope::apns_body("payload", Urgency::Background).expect("body fits");
let parsed: serde_json::Value = serde_json::from_slice(&body).expect("body is json");
assert_eq!(parsed["aps"]["content-available"], 1);
assert!(parsed["aps"].get("alert").is_none());
let headers = envelope::apns_headers(Urgency::Background, 0, 86_400);
let push_type = headers
.iter()
.find(|(name, _)| name == "apns-push-type")
.map(|(_, value)| value.as_str());
assert_eq!(push_type, Some("background"));
}
#[test]
fn payload_too_large_answers_413() {
assert_eq!(