diff --git a/autopush/webpush_server.py b/autopush/webpush_server.py index c9475659..e9e3ed0d 100644 --- a/autopush/webpush_server.py +++ b/autopush/webpush_server.py @@ -115,7 +115,7 @@ def to_WebPushNotification(self): ) # If there's no sortkey_timestamp and no topic, its legacy - if not notif.sortkey_timestamp and not notif.topic: + if notif.sortkey_timestamp is None and not notif.topic: notif.legacy = True return notif diff --git a/autopush_rs/src/client.rs b/autopush_rs/src/client.rs index aa80d4cf..5d372790 100644 --- a/autopush_rs/src/client.rs +++ b/autopush_rs/src/client.rs @@ -493,7 +493,14 @@ where let unacked_direct_notifs = webpush.unacked_direct_notifs.len(); if unacked_direct_notifs > 0 { stats.direct_storage += unacked_direct_notifs as i32; - let notifs = mem::replace(&mut webpush.unacked_direct_notifs, Vec::new()); + let mut notifs = mem::replace(&mut webpush.unacked_direct_notifs, Vec::new()); + // Ensure we don't store these as legacy by setting a 0 as the sortkey_timestamp + // That will ensure the Python side doesn't mark it as legacy during conversion and + // still get the correct default us_time when saving. + for notif in notifs.iter_mut() { + notif.sortkey_timestamp = Some(0); + } + srv.handle.spawn(srv.store_messages( webpush.uaid.simple().to_string(), webpush.message_month.clone(),