From a218b5bf8715f97e820dc30571993ec7203b9f9c Mon Sep 17 00:00:00 2001 From: Ben Bangert Date: Fri, 4 May 2018 15:49:52 -0700 Subject: [PATCH] fix: don't save legacy messages from the Rust node Closes #1198 --- autopush/webpush_server.py | 2 +- autopush_rs/src/client.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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(),