From db24f262b3ba98e7c1b2826a112bd73c708cb216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lucas=20de=20Oliveira=20Lopes?= Date: Thu, 19 Nov 2026 01:27:53 -0300 Subject: [PATCH] fix(sdk): adapt client timestamp boundaries --- Cargo.lock | 333 ++++++++---------- crates/chat-store/src/queries.rs | 4 +- crates/chat-store/src/store/ack.rs | 2 +- crates/chat-store/src/store/avatar.rs | 2 +- crates/chat-store/src/store/event.rs | 10 +- .../chat-store/src/store/group_membership.rs | 4 +- crates/chat-store/src/store/history_sync.rs | 2 +- crates/chat-store/src/store/inbound.rs | 2 +- .../chat-store/src/store/message_identity.rs | 4 +- crates/chat-store/src/store/mod.rs | 6 +- .../chat-store/src/store/offline_receipts.rs | 6 +- crates/chat-store/src/store/receipt.rs | 2 +- crates/chat-store/src/store/shared_history.rs | 4 +- crates/chat-store/src/store/writer.rs | 10 +- crates/chat-store/tests/common/mod.rs | 14 +- crates/chat-store/tests/contact_removed.rs | 4 +- crates/chat-store/tests/group_membership.rs | 2 +- crates/chat-store/tests/history_sync.rs | 8 +- crates/chat-store/tests/lid.rs | 6 +- crates/chat-store/tests/messages.rs | 2 +- crates/chat-store/tests/mute.rs | 10 +- crates/chat-store/tests/offline_receipts.rs | 10 +- crates/chat-store/tests/operation_acks.rs | 4 +- crates/chat-store/tests/outgoing.rs | 4 +- crates/chat-store/tests/pagination.rs | 2 +- crates/chat-store/tests/read_state.rs | 52 +-- crates/chat-store/tests/receipts.rs | 4 +- crates/chat-store/tests/regression_194.rs | 2 +- crates/chat-store/tests/regression_212.rs | 20 +- crates/chat-store/tests/regression_232.rs | 8 +- crates/chat-store/tests/scoped_activity.rs | 2 +- crates/chat-store/tests/shared_history.rs | 6 +- crates/chat-store/tests/status_watch.rs | 4 +- crates/chat-store/tests/writer.rs | 4 +- crates/core/src/call.rs | 6 +- crates/core/src/calls.rs | 17 +- crates/core/src/chat/message.rs | 4 +- crates/core/src/lib.rs | 1 + crates/core/src/presence.rs | 8 +- crates/core/src/status.rs | 2 +- crates/core/src/time.rs | 38 ++ crates/daemon/src/account/retirement.rs | 2 +- crates/daemon/src/session_bridge/call_log.rs | 2 +- crates/daemon/src/session_bridge/mod.rs | 2 +- crates/daemon/src/session_bridge/tests.rs | 2 +- .../daemon/src/session_bridge/wire_events.rs | 4 +- crates/daemon/src/state/mod.rs | 2 +- crates/daemon/src/state/store.rs | 12 +- crates/gui/src/app/calls_ctl.rs | 8 +- crates/gui/src/app/calls_ctl/alerts.rs | 2 +- crates/gui/src/app/events.rs | 8 +- crates/gui/src/app/notices.rs | 4 +- crates/gui/src/app/recovery.rs | 15 +- crates/gui/src/app/status.rs | 4 +- crates/gui/src/components/chat_item.rs | 2 +- crates/gui/src/components/status/list.rs | 2 +- .../src/platform/notifications/call_alert.rs | 8 +- crates/gui/src/utils.rs | 12 +- crates/gui/src/views/pairing.rs | 2 +- crates/plugin-host/src/tests.rs | 2 +- crates/session/src/store/registry.rs | 10 +- crates/session/src/whatsapp/calls/registry.rs | 8 +- crates/session/src/whatsapp/convert.rs | 2 +- crates/session/src/whatsapp/mod.rs | 40 ++- crates/session/src/whatsapp/mutations.rs | 11 +- crates/session/src/whatsapp/ops.rs | 4 +- crates/session/src/whatsapp/sends.rs | 2 +- crates/session/src/whatsapp/sticker_sync.rs | 2 +- crates/session/src/whatsapp/tests.rs | 21 +- crates/session/src/whatsapp/ui_queue.rs | 2 +- 70 files changed, 436 insertions(+), 396 deletions(-) create mode 100644 crates/core/src/time.rs diff --git a/Cargo.lock b/Cargo.lock index 5b65cc569..43629e2c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -946,7 +946,7 @@ version = "3.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93833e97ac7c46ba97045afcf247238c27057538fcf2f06344662ddd5f567be6" dependencies = [ - "darling 0.24.1", + "darling", "ident_case", "prettyplease 0.3.0", "proc-macro2", @@ -1982,64 +1982,14 @@ dependencies = [ "cmov", ] -[[package]] -name = "curve25519-dalek" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23" -dependencies = [ - "cfg-if 1.0.5", - "cpufeatures 0.3.1", - "curve25519-dalek-derive", - "fiat-crypto", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "darling" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" -dependencies = [ - "darling_core 0.21.3", - "darling_macro 0.21.3", -] - [[package]] name = "darling" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" dependencies = [ - "darling_core 0.24.1", - "darling_macro 0.24.1", -] - -[[package]] -name = "darling_core" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.119", + "darling_core", + "darling_macro", ] [[package]] @@ -2055,24 +2005,13 @@ dependencies = [ "syn 3.0.9", ] -[[package]] -name = "darling_macro" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" -dependencies = [ - "darling_core 0.21.3", - "quote", - "syn 2.0.119", -] - [[package]] name = "darling_macro" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" dependencies = [ - "darling_core 0.24.1", + "darling_core", "quote", "syn 3.0.9", ] @@ -2199,36 +2138,51 @@ dependencies = [ [[package]] name = "diesel" -version = "2.3.14" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe9f7eaef33febd60290c5a9f3b0571d03c4c04a24739cd64808ce30e65a5d3" +checksum = "9824c36a57a17ece4c8883baed41dc3eb81b2b949364c174750acc462e19b5ec" dependencies = [ + "bitflags 2.13.2", "diesel_derives", "downcast-rs 2.0.2", "libsqlite3-sys", "r2d2", + "serde_json", "sqlite-wasm-rs", + "sqlstate", "time", ] +[[package]] +name = "diesel_attribute_parser" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de6c008369e0bc4e26f385874b8d1da517112b4ebe2f8e6b1e3331c781039d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "diesel_derives" -version = "2.3.10" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecbd51fb6c020672543641167efa4e6417ff7ad76849ed556ace3595e72de03a" +checksum = "90c0b085880f70a6668dd2365040f4dd07aaf6ebe9e6b8626528efcb0553a780" dependencies = [ + "diesel_attribute_parser", "diesel_table_macro_syntax", "dsl_auto_type", "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] name = "diesel_migrations" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d0f4a98124ba6d4ca75da535f65984badec16a003b6e2f94a01e31a79490b8" +checksum = "08c9f048650c19d17cbe5918afd81d21a5c1c92f5f37dd9a66846958cd81c3c0" dependencies = [ "diesel", "migrations_internals", @@ -2237,11 +2191,11 @@ dependencies = [ [[package]] name = "diesel_table_macro_syntax" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe2444076b48641147115697648dc743c2c00b61adade0f01ce67133c7babe8c" +checksum = "d05c7977b58892eda3f17d46fd57fb23e865d1e54f59b224a6cc09935013747c" dependencies = [ - "syn 2.0.119", + "syn 3.0.9", ] [[package]] @@ -2354,16 +2308,16 @@ checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" [[package]] name = "dsl_auto_type" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd122633e4bef06db27737f21d3738fb89c8f6d5360d6d9d7635dda142a7757e" +checksum = "cc51ea5a4c1cfac05a51e51cdbb6a5471bbb88091fcb045a27ff13b38e9a3204" dependencies = [ - "darling 0.21.3", + "darling", "either", "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] @@ -2568,7 +2522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2660,12 +2614,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "fiat-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" - [[package]] name = "filedescriptor" version = "0.8.3" @@ -3329,7 +3277,7 @@ dependencies = [ "objc2-core-foundation", "objc2-core-video", "parking", - "parking_lot", + "parking_lot 0.12.5", "pin-project", "pollster 0.4.0", "postage", @@ -3393,7 +3341,7 @@ dependencies = [ "objc2-metal 0.3.2", "objc2-quartz-core 0.3.2", "objc2-security", - "parking_lot", + "parking_lot 0.12.5", "pathfinder_geometry", "smallvec", "thiserror 2.0.21", @@ -3426,7 +3374,7 @@ dependencies = [ "notify-rust", "oo7", "open", - "parking_lot", + "parking_lot 0.12.5", "raw-window-handle", "smallvec", "smol", @@ -3478,7 +3426,7 @@ dependencies = [ "objc2-quartz-core 0.3.2", "objc2-uniform-type-identifiers", "objc2-user-notifications", - "parking_lot", + "parking_lot 0.12.5", "raw-window-handle", "semver", "smallvec", @@ -3528,7 +3476,7 @@ dependencies = [ "gpui-pre-scheduler", "js-sys", "log", - "parking_lot", + "parking_lot 0.12.5", "raw-window-handle", "smallvec", "unicode-properties", @@ -3558,7 +3506,7 @@ dependencies = [ "image", "itertools 0.14.0", "log", - "parking_lot", + "parking_lot 0.12.5", "profiling", "raw-window-handle", "smallvec", @@ -3589,7 +3537,7 @@ dependencies = [ "image", "itertools 0.14.0", "log", - "parking_lot", + "parking_lot 0.12.5", "rand 0.9.5", "raw-window-handle", "smallvec", @@ -3653,7 +3601,7 @@ dependencies = [ "objc2-core-foundation", "objc2-core-video", "parking", - "parking_lot", + "parking_lot 0.12.5", "pin-project", "pollster 0.4.0", "profiling", @@ -3714,7 +3662,7 @@ dependencies = [ "objc2-metal 0.3.2", "objc2-quartz-core 0.3.2", "objc2-security", - "parking_lot", + "parking_lot 0.12.5", "pathfinder_geometry", "smallvec", "thiserror 2.0.21", @@ -3767,7 +3715,7 @@ dependencies = [ "http", "http-body", "log", - "parking_lot", + "parking_lot 0.12.5", "serde", "serde_json", "serde_urlencoded", @@ -3791,7 +3739,7 @@ dependencies = [ "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", "objc2-ui-kit", - "parking_lot", + "parking_lot 0.12.5", "raw-window-handle", "uuid", ] @@ -3879,7 +3827,7 @@ dependencies = [ "chrono", "flume 0.12.0", "futures", - "parking_lot", + "parking_lot 0.12.5", "rand 0.9.5", "wasm_thread", "web-time", @@ -4268,7 +4216,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.58.0", + "windows-core 0.57.0", ] [[package]] @@ -4964,9 +4912,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.38.2" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d20bef17f513b9b3004532233187769cd072d790971f4e4da0e346eb6401e8" +checksum = "b06e69070b7e12262b0cd90832f0a7396f142a2b330181255562decf9f0c6215" dependencies = [ "cc", "pkg-config", @@ -5030,6 +4978,15 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "lock_api" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65d91b22da179613dcf4d6ec8349563f52a363f6849e03b00dd0a185ec4a59af" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.34" @@ -5356,19 +5313,19 @@ dependencies = [ [[package]] name = "migrations_internals" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c791ecdf977c99f45f23280405d7723727470f6689a5e6dbf513ac547ae10d" +checksum = "ec54a4ea92c533f8ed6b8c80dc4bbd60f5b578b173399d92f19bfb5a34bd99a3" dependencies = [ "serde", - "toml 0.9.12+spec-1.1.0", + "toml 1.1.8+spec-1.1.0", ] [[package]] name = "migrations_macros" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9423d6affd681fb4d25d35885d0d0262c52f8ade16e96f87c064c442e5aa5d47" +checksum = "befb6974b8d7e9d8c48865f5f38f170f0db42faacdbc54682846bee108e0ef81" dependencies = [ "migrations_internals", "proc-macro2", @@ -6894,8 +6851,18 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ - "lock_api", - "parking_lot_core", + "lock_api 0.4.14", + "parking_lot_core 0.9.12", +] + +[[package]] +name = "parking_lot" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9cf937ca4e1d0b7578784559063422fc39ae7c5a00f02471f2614d5486fd226" +dependencies = [ + "lock_api 0.5.0", + "parking_lot_core 0.10.0", ] [[package]] @@ -6906,7 +6873,19 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if 1.0.5", "libc", - "redox_syscall", + "redox_syscall 0.5.18", + "smallvec", + "windows-link 0.2.1", +] + +[[package]] +name = "parking_lot_core" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cfff060068cc18aa7815010fcaf80c68c7fb9e85fc7f5c0f9bf142c21d19826" +dependencies = [ + "libc", + "redox_syscall 0.9.5", "smallvec", "windows-link 0.2.1", ] @@ -7296,7 +7275,7 @@ checksum = "af3fb618632874fb76937c2361a7f22afd393c982a2165595407edc75b06d3c1" dependencies = [ "atomic", "crossbeam-queue", - "parking_lot", + "parking_lot 0.12.5", "pin-project", "pollster 0.2.5", "static_assertions", @@ -7585,7 +7564,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -7616,7 +7595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93" dependencies = [ "log", - "parking_lot", + "parking_lot 0.12.5", "scheduled-thread-pool", ] @@ -7883,6 +7862,15 @@ dependencies = [ "bitflags 2.13.2", ] +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + [[package]] name = "redox_users" version = "0.4.6" @@ -8135,9 +8123,9 @@ dependencies = [ [[package]] name = "rtc-datachannel" -version = "0.21.0-beta.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0180e434128b3a3e9d8552ea958fd588839266cf08a2625741fbe65c292d1cb8" +checksum = "8d93dd81014535ff0134c0f19dbccfbae4d5ceb6010cf917c1a6056ea2c0d9bb" dependencies = [ "bytes", "log", @@ -8148,9 +8136,9 @@ dependencies = [ [[package]] name = "rtc-dtls" -version = "0.21.0-beta.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cb87e1ec1b828914aace884307974a9ed40747e2f6ccaab93a4fff42528a73" +checksum = "0a2fe5767d6caf61018d52189b3b8e37075799eeb81cd5ab452307c7e7ebd97e" dependencies = [ "bytecheck", "byteorder", @@ -8168,9 +8156,9 @@ dependencies = [ [[package]] name = "rtc-sctp" -version = "0.21.0-beta.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9dabdca726a7c5eed4d4ae5f3f9d4e9baf7a2ed53efaedaae35b4bcc24bc2a" +checksum = "2eb430b379d90e7984306036d1646454a26b300c9c3256009eb8f7e0615e90b9" dependencies = [ "bytes", "crc32c", @@ -8184,9 +8172,9 @@ dependencies = [ [[package]] name = "rtc-shared" -version = "0.21.0-beta.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "998b045d95d158251842c5146918f3213346ca7724e8c6ac750c37d467dbbcdd" +checksum = "1250e81796ac6d3d67bd04ecdb891b8371ff97c8a2ce0a5a1c1321f2e12b657b" dependencies = [ "bitflags 1.3.2", "bytes", @@ -8343,7 +8331,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -8480,11 +8468,11 @@ dependencies = [ [[package]] name = "scheduled-thread-pool" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbc66816425a074528352f5789333ecff06ca41b36b0b0efdfbb29edc391a19" +checksum = "f304b290c05b371b2aa1e8718242ff0394530f9334ecedcb9ae51330f37fc1ba" dependencies = [ - "parking_lot", + "parking_lot 0.13.0", ] [[package]] @@ -8989,7 +8977,7 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" dependencies = [ - "lock_api", + "lock_api 0.4.14", ] [[package]] @@ -8998,7 +8986,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3" dependencies = [ - "lock_api", + "lock_api 0.4.14", ] [[package]] @@ -9038,6 +9026,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "sqlstate" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "858cea190fe7555971c35a5eb336858f1bf962a2bd7ceb8704fb1759b36af2cd" + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -9082,7 +9076,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" dependencies = [ "new_debug_unreachable", - "parking_lot", + "parking_lot 0.12.5", "phf_shared 0.11.3", "precomputed-hash", "serde", @@ -9413,10 +9407,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.3", + "getrandom 0.3.4", "once_cell", "rustix 1.1.6", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -9694,19 +9688,6 @@ dependencies = [ "toml_edit 0.22.27", ] -[[package]] -name = "toml" -version = "0.9.12+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" -dependencies = [ - "serde_core", - "serde_spanned 1.1.2", - "toml_datetime 0.7.5+spec-1.1.0", - "toml_parser", - "winnow 0.7.15", -] - [[package]] name = "toml" version = "1.1.8+spec-1.1.0" @@ -9731,15 +9712,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_datetime" -version = "0.7.5+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" -dependencies = [ - "serde_core", -] - [[package]] name = "toml_datetime" version = "1.1.2+spec-1.1.0" @@ -10277,7 +10249,7 @@ dependencies = [ [[package]] name = "wacore" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "aes 0.9.3", "aes-gcm", @@ -10291,7 +10263,6 @@ dependencies = [ "buffa-build", "bytes", "cbc 0.2.1", - "chrono", "compact_str", "ctr 0.10.1", "event-listener", @@ -10327,7 +10298,7 @@ dependencies = [ [[package]] name = "wacore-appstate" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "anyhow", "buffa", @@ -10339,6 +10310,7 @@ dependencies = [ "serde-big-array", "serde_json", "sha2 0.11.1", + "subtle", "thiserror 2.0.21", "wacore-binary", "wacore-libsignal", @@ -10348,13 +10320,15 @@ dependencies = [ [[package]] name = "wacore-binary" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "bytes", "compact_str", + "getrandom 0.4.3", "itoa", "serde", "serde_json", + "siphasher", "smallvec", "smoothutf8", "stable_deref_trait", @@ -10365,7 +10339,7 @@ dependencies = [ [[package]] name = "wacore-derive" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "proc-macro2", "quote", @@ -10375,38 +10349,37 @@ dependencies = [ [[package]] name = "wacore-libsignal" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "aes 0.9.3", + "aes-gcm", + "arrayvec", "async-lock", "async-trait", "buffa", "bytes", "cbc 0.2.1", - "chrono", "ctr 0.10.1", - "curve25519-dalek", - "ghash", "hex", "hkdf 0.13.0", "hmac 0.13.0", + "itoa", "log", "portable-atomic", "rand 0.10.3", "serde", - "sha1 0.11.0", "sha2 0.11.1", "subtle", "thiserror 2.0.21", - "wacore-derive", + "wacore-binary", "waproto", - "x25519-dalek", + "zeroize", ] [[package]] name = "wacore-noise" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "anyhow", "buffa", @@ -10458,7 +10431,7 @@ dependencies = [ [[package]] name = "waproto" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "buffa", "buffa-build", @@ -10850,7 +10823,7 @@ dependencies = [ "js-sys", "log", "naga", - "parking_lot", + "parking_lot 0.12.5", "portable-atomic", "profiling", "raw-window-handle", @@ -10883,7 +10856,7 @@ dependencies = [ "naga", "naga-types", "once_cell", - "parking_lot", + "parking_lot 0.12.5", "portable-atomic", "profiling", "raw-window-handle", @@ -10970,7 +10943,7 @@ dependencies = [ "objc2-quartz-core 0.3.2", "once_cell", "ordered-float", - "parking_lot", + "parking_lot 0.12.5", "portable-atomic", "portable-atomic-util", "profiling", @@ -11020,7 +10993,7 @@ dependencies = [ [[package]] name = "whatsapp-rust" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "anyhow", "async-channel", @@ -11030,7 +11003,6 @@ dependencies = [ "bon", "buffa", "bytes", - "chrono", "event-listener", "flate2", "futures", @@ -11068,7 +11040,7 @@ dependencies = [ [[package]] name = "whatsapp-rust-sqlite-storage" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "async-trait", "buffa", @@ -11091,7 +11063,7 @@ dependencies = [ [[package]] name = "whatsapp-rust-tokio-transport" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "anyhow", "async-channel", @@ -11111,7 +11083,7 @@ dependencies = [ [[package]] name = "whatsapp-rust-ureq-http-client" version = "0.7.0" -source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#aab35eb4954dfc6d2def988e752bb8733f077af6" +source = "git+https://github.com/oxidezap/whatsapp-rust?branch=main#14661bb400be0b1d68a1b92064f847894ecf6c41" dependencies = [ "anyhow", "async-trait", @@ -11173,7 +11145,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] @@ -11233,7 +11205,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a4df73e95feddb9ec1a7e9c2ca6323b8c97d5eeeff78d28f1eccdf19c882b24" dependencies = [ - "parking_lot", + "parking_lot 0.12.5", "rayon", "thiserror 2.0.21", "windows 0.61.3", @@ -11843,17 +11815,6 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" -[[package]] -name = "x25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e8131a03190127fb2263afc72b322ecadae46b6ff8c6f399ff5d02f5559af6" -dependencies = [ - "curve25519-dalek", - "rand_core 0.10.1", - "zeroize", -] - [[package]] name = "x509-parser" version = "0.16.0" diff --git a/crates/chat-store/src/queries.rs b/crates/chat-store/src/queries.rs index 6604a70ff..54760f672 100644 --- a/crates/chat-store/src/queries.rs +++ b/crates/chat-store/src/queries.rs @@ -820,7 +820,7 @@ impl ChatStore { let device_id = self.device_id(); let is_group = jid.is_group(); let jid = jid.to_string(); - let now_ms = wacore::time::now_utc().timestamp_millis(); + let now_ms = wacore::time::now_millis(); let rows: Vec<(Option, bool, Option)> = self .db() .read(move |conn| { @@ -2366,7 +2366,7 @@ impl ChatStore { ) -> Result<()> { use schema::media_refs::dsl; let device_id = self.device_id(); - let now_ms = wacore::time::now_utc().timestamp_millis(); + let now_ms = wacore::time::now_millis(); self.db() .run(move |conn| { diesel::insert_into(dsl::media_refs) diff --git a/crates/chat-store/src/store/ack.rs b/crates/chat-store/src/store/ack.rs index b6f6e4c3e..3a08dc827 100644 --- a/crates/chat-store/src/store/ack.rs +++ b/crates/chat-store/src/store/ack.rs @@ -485,7 +485,7 @@ pub(super) fn apply_server_ack( let server_timestamp_ms = ack .timestamp .filter(|_| ack.error.is_none()) - .map(|timestamp| timestamp.timestamp_millis()); + .map(wacore::Timestamp::as_millis); let timestamp_updated = if let Some(timestamp_ms) = server_timestamp_ms { diesel::update( message_row(device_id, &chat, &ack.id) diff --git a/crates/chat-store/src/store/avatar.rs b/crates/chat-store/src/store/avatar.rs index 51de1a30a..94516a7ff 100644 --- a/crates/chat-store/src/store/avatar.rs +++ b/crates/chat-store/src/store/avatar.rs @@ -106,7 +106,7 @@ pub(super) fn upsert( ) -> QueryResult<()> { use schema::avatar_descriptors::dsl; let jid = jid.to_string(); - let now_ms = wacore::time::now_utc().timestamp_millis(); + let now_ms = wacore::time::now_millis(); let seq = i64::try_from(seq).unwrap_or(i64::MAX); if !picture_id.is_empty() && seq <= order_floor(conn, device_id)? { let present = dsl::avatar_descriptors diff --git a/crates/chat-store/src/store/event.rs b/crates/chat-store/src/store/event.rs index 86d70b29c..46228aec5 100644 --- a/crates/chat-store/src/store/event.rs +++ b/crates/chat-store/src/store/event.rs @@ -48,7 +48,7 @@ pub(super) fn apply_event( if let AckApplied::Deferrable(chat) = apply_server_ack_with_operations(conn, device_id, ack, cs, deferred)? { - deferred.defer(ack, chat, wacore::time::now_utc().timestamp_millis()); + deferred.defer(ack, chat, wacore::time::now_millis()); } Ok(()) } @@ -64,7 +64,7 @@ pub(super) fn apply_event( msg_id: &undec.info.id, sender_jid: &sender, from_me: undec.info.source.is_from_me, - timestamp_ms: undec.info.timestamp.timestamp_millis(), + timestamp_ms: undec.info.timestamp.as_millis(), kind, text: None, proto: None, @@ -86,7 +86,7 @@ pub(super) fn apply_event( &chat, ChatBump { msg_id: &undec.info.id, - ts_ms: undec.info.timestamp.timestamp_millis(), + ts_ms: undec.info.timestamp.as_millis(), preview: None, kind: Some(kind), unread_delta: i32::from(!undec.info.source.is_from_me), @@ -172,7 +172,7 @@ pub(super) fn apply_event( .action .pinned .unwrap_or(false) - .then(|| update.timestamp.timestamp_millis()); + .then(|| update.timestamp.as_millis()); let chat = crate::lid::route_chat_key(conn, device_id, &update.jid.to_string(), cs)?; crate::store::chat_rows::ensure_preference_chat(conn, device_id, &chat)?; // Only when it is news, the same rule the subject change already @@ -293,7 +293,7 @@ pub(super) fn apply_event( // stale replay resurrects a badge this read cleared. let watermark = newest .flatten() - .unwrap_or_else(|| update.timestamp.timestamp_millis()); + .unwrap_or_else(|| update.timestamp.as_millis()); advance_read_state(conn, device_id, &chat, watermark, &[])? } }; diff --git a/crates/chat-store/src/store/group_membership.rs b/crates/chat-store/src/store/group_membership.rs index f3e5bd471..b72a49622 100644 --- a/crates/chat-store/src/store/group_membership.rs +++ b/crates/chat-store/src/store/group_membership.rs @@ -36,7 +36,7 @@ pub(super) fn apply( msg_id: &id, sender_jid: &chat, from_me: false, - timestamp_ms: update.timestamp.timestamp_millis(), + timestamp_ms: update.timestamp.as_millis(), kind: "group_membership", text: None, proto: None, @@ -68,7 +68,7 @@ pub(super) fn apply( &chat, ChatBump { msg_id: &id, - ts_ms: update.timestamp.timestamp_millis(), + ts_ms: update.timestamp.as_millis(), preview: Some(&preview), kind: Some("group_membership"), unread_delta: 0, diff --git a/crates/chat-store/src/store/history_sync.rs b/crates/chat-store/src/store/history_sync.rs index 70e54af5e..0e6e1f812 100644 --- a/crates/chat-store/src/store/history_sync.rs +++ b/crates/chat-store/src/store/history_sync.rs @@ -228,7 +228,7 @@ fn apply_history_conversation( // cover is durable for every row, so an oversized snapshot seeds // nothing at all and leaves the stored count (and later merges, // which keep a stored zero over an unset marker) alone. - let now_ms = wacore::time::now_utc().timestamp_millis(); + let now_ms = wacore::time::now_millis(); let frontier_ms = last_ts_ms.max(synced_max_ms).min(now_ms); // Appending past the retained-id cap would evict older explicitly // covered ids — possibly for rows not yet materialized — so only diff --git a/crates/chat-store/src/store/inbound.rs b/crates/chat-store/src/store/inbound.rs index 0fa4a7ca2..ed168dab0 100644 --- a/crates/chat-store/src/store/inbound.rs +++ b/crates/chat-store/src/store/inbound.rs @@ -25,7 +25,7 @@ pub(super) fn apply_inbound( let info = &inbound.info; let chat = route_chat(conn, device_id, info.source.chat.to_string(), cs)?; let sender = info.source.sender.to_string(); - let ts_ms = info.timestamp.timestamp_millis(); + let ts_ms = info.timestamp.as_millis(); // Live push names ride on every message; keep contacts warm from them. if !info.push_name.is_empty() && !info.source.is_from_me { diff --git a/crates/chat-store/src/store/message_identity.rs b/crates/chat-store/src/store/message_identity.rs index 62f032a4c..e50bcf889 100644 --- a/crates/chat-store/src/store/message_identity.rs +++ b/crates/chat-store/src/store/message_identity.rs @@ -396,7 +396,7 @@ pub(crate) fn reconcile_startup( /// the history-sync seed) makes that zero durable across later repairs. /// Runs exactly on the dirty startups that precede a full repair. fn backfill_legacy_read_state(conn: &mut SqliteConnection, device_id: i32) -> QueryResult<()> { - let now_ms = wacore::time::now_utc().timestamp_millis(); + let now_ms = wacore::time::now_millis(); // Chats the scalar sweep cannot fully cover: rows timestamped ahead of // the capped frontier need explicit ids or the repair below recounts // them. Selected up front, while the sweep predicate still identifies @@ -804,7 +804,7 @@ fn refresh_chat_after_merge( .select(diesel::dsl::max(schema::messages::timestamp_ms)) .first(conn)?; if let Some(max_ts) = max_ts.filter(|&ts| ts > 0) { - let baseline = max_ts.min(wacore::time::now_utc().timestamp_millis()); + let baseline = max_ts.min(wacore::time::now_millis()); // Past more coverable ids than the retained list holds, a // committed scalar without its ids would leave the next // merge recounting the uncovered rows — so an overflowing diff --git a/crates/chat-store/src/store/mod.rs b/crates/chat-store/src/store/mod.rs index 49232fa0b..e2406bdbf 100644 --- a/crates/chat-store/src/store/mod.rs +++ b/crates/chat-store/src/store/mod.rs @@ -981,7 +981,11 @@ impl ChatStore { .maybe_participant_jid(participant) .message_id(target_id.to_owned()) .from_me(from_me) - .timestamp(timestamp) + .timestamp( + wacore::Timestamp::from_millis(timestamp.timestamp_millis()).ok_or_else(|| { + StoreError::Validation("delete timestamp is outside the SDK range".into()) + })?, + ) .action(Box::new({ let mut constructed: wa::sync_action_value::DeleteMessageForMeAction = Default::default(); diff --git a/crates/chat-store/src/store/offline_receipts.rs b/crates/chat-store/src/store/offline_receipts.rs index 5115c7bf7..d8b029e67 100644 --- a/crates/chat-store/src/store/offline_receipts.rs +++ b/crates/chat-store/src/store/offline_receipts.rs @@ -29,7 +29,7 @@ pub(super) fn retain( timestamp: i64, ) -> QueryResult<()> { use diesel::query_dsl::methods::FilterDsl; - let now = wacore::time::now_utc().timestamp_millis(); + let now = wacore::time::now_millis(); diesel::insert_into(pending::table) .values(( pending::device_id.eq(device), @@ -56,7 +56,7 @@ pub(super) fn retain( /// Enforce retention once per batch, after matching available outgoing rows. pub(super) fn prune(conn: &mut SqliteConnection, device: i32) -> QueryResult<()> { - let now = wacore::time::now_utc().timestamp_millis(); + let now = wacore::time::now_millis(); diesel::sql_query( "DELETE FROM offline_receipts WHERE device_id = ? AND \ (received_at_ms < ? OR rowid IN (SELECT rowid FROM offline_receipts \ @@ -91,7 +91,7 @@ pub(super) fn apply( pending::received_at_ms, )) .load::<(String, String, String, i32, i64, i64)>(conn)?; - let cutoff = wacore::time::now_utc().timestamp_millis() - RETENTION_MS; + let cutoff = wacore::time::now_millis() - RETENTION_MS; for (wire_chat, id, user, status, timestamp, received) in rows { let owner = messages::table .filter(messages::device_id.eq(device)) diff --git a/crates/chat-store/src/store/receipt.rs b/crates/chat-store/src/store/receipt.rs index 25a6ba4c2..cc4f875f8 100644 --- a/crates/chat-store/src/store/receipt.rs +++ b/crates/chat-store/src/store/receipt.rs @@ -24,7 +24,7 @@ pub(super) fn apply_receipt( // pipeline and the receipt echo need the full JID, so a companion device // acking a DM arrives as `user:48@lid`. Rows are keyed bare. let chat = receipt.source.chat.to_non_ad_string(); - let ts_ms = receipt.timestamp.timestamp_millis(); + let ts_ms = receipt.timestamp.as_millis(); let message_ids: Vec = receipt .message_ids .iter() diff --git a/crates/chat-store/src/store/shared_history.rs b/crates/chat-store/src/store/shared_history.rs index eb100c650..cc616cd47 100644 --- a/crates/chat-store/src/store/shared_history.rs +++ b/crates/chat-store/src/store/shared_history.rs @@ -253,7 +253,7 @@ pub(super) fn apply( if let Some(context) = base.context_info() && context.expiration.is_some_and(|duration| { duration > 0 - && ts.saturating_add(i64::from(duration)) <= wacore::time::now_utc().timestamp() + && ts.saturating_add(i64::from(duration)) <= wacore::time::now_utc().as_secs() }) { continue; @@ -339,7 +339,7 @@ pub(super) fn attempted( bundle: &PendingHistoryBundle, ) -> QueryResult<()> { diesel::sql_query("UPDATE shared_group_history SET attempted_ms = ? WHERE device_id = ? AND chat_jid = ? AND msg_id = ? AND sender_jid = ?") - .bind::(wacore::time::now_utc().timestamp_millis()) + .bind::(wacore::time::now_millis()) .bind::(device).bind::(&bundle.chat_jid).bind::(&bundle.msg_id).bind::(&bundle.sender_jid).execute(conn)?; Ok(()) } diff --git a/crates/chat-store/src/store/writer.rs b/crates/chat-store/src/store/writer.rs index 2573c55a0..739d6acfb 100644 --- a/crates/chat-store/src/store/writer.rs +++ b/crates/chat-store/src/store/writer.rs @@ -402,7 +402,7 @@ fn apply_writer_msg( device_id, &chat.to_string(), operation_id, - wacore::time::now_utc().timestamp_millis(), + wacore::time::now_millis(), ), WriterMsg::InboundDurability { event, .. } => { apply_event(conn, device_id, event, cs, deferred) @@ -498,11 +498,9 @@ fn apply_writer_msg( // The row this send's ack was waiting for now exists. Applying // it here also corrects the optimistic timestamp we just wrote // to the server's, before anything renders the row. - while let Some(ack) = deferred.take_matching( - msg_id, - &chat_str, - wacore::time::now_utc().timestamp_millis(), - ) { + while let Some(ack) = + deferred.take_matching(msg_id, &chat_str, wacore::time::now_millis()) + { if let AckApplied::Deferrable(_) = apply_server_ack_with_operations(conn, device_id, &ack, cs, deferred)? { diff --git a/crates/chat-store/tests/common/mod.rs b/crates/chat-store/tests/common/mod.rs index 778ebc8bc..ee959fc67 100644 --- a/crates/chat-store/tests/common/mod.rs +++ b/crates/chat-store/tests/common/mod.rs @@ -79,6 +79,10 @@ pub fn jid(s: &str) -> Jid { /// The tests date everything from 1_700_000_000 and step by seconds, so this /// is the one spelling of `Utc.timestamp_opt(secs, 0).unwrap()` — which was /// written out at every one of a hundred and thirty-seven sites. +pub fn sdk_timestamp(time: DateTime) -> wacore::Timestamp { + wacore::Timestamp::from_millis(time.timestamp_millis()).unwrap() +} + pub fn ts(secs: i64) -> DateTime { DateTime::from_timestamp(secs, 0).expect("a representable test instant") } @@ -93,7 +97,7 @@ pub fn incoming_info(chat: &str, sender: &str, id: &str, ts_secs: i64) -> Messag ..Default::default() }, id: id.to_string().into(), - timestamp: ts(ts_secs), + timestamp: sdk_timestamp(ts(ts_secs)), ..Default::default() } } @@ -180,7 +184,7 @@ fn built_receipt( ..Default::default() }) .message_ids(ids.iter().map(|id| (*id).into()).collect()) - .timestamp(at) + .timestamp(sdk_timestamp(at)) .r#type(ty) .offline(offline) .build(), @@ -236,7 +240,7 @@ fn built_ack(id: &str, chat: Option, at: Option>, code: Optio .id(id.to_string()) .class("message".to_string()) .maybe_from(chat) - .maybe_timestamp(at) + .maybe_timestamp(at.map(sdk_timestamp)) .maybe_error(code.map(str::to_string)) .build(), ) @@ -276,7 +280,7 @@ pub fn delete_for_me(chat: Jid, id: &str, from_me: bool, at: DateTime) -> E .chat_jid(chat) .message_id(id.to_string()) .from_me(from_me) - .timestamp(at) + .timestamp(sdk_timestamp(at)) .action(Box::new( wa::sync_action_value::DeleteMessageForMeAction::default(), )) @@ -300,7 +304,7 @@ pub fn mark_read_event(chat: &str, read: bool, ts_secs: i64) -> Event { Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(chat)) - .timestamp(ts(ts_secs)) + .timestamp(sdk_timestamp(ts(ts_secs))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); diff --git a/crates/chat-store/tests/contact_removed.rs b/crates/chat-store/tests/contact_removed.rs index 99a0bcbf6..7439e3ca1 100644 --- a/crates/chat-store/tests/contact_removed.rs +++ b/crates/chat-store/tests/contact_removed.rs @@ -8,7 +8,7 @@ fn contact_update(jid: &str, full_name: &str, first_name: &str) -> Event { Event::ContactUpdate( ContactUpdate::builder() .jid(jid.parse().expect("test JID")) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new({ let mut constructed: wa::sync_action_value::ContactAction = Default::default(); constructed.full_name = Some(full_name.to_owned()); @@ -24,7 +24,7 @@ fn contact_removed(jid: &str) -> Event { Event::ContactRemoved( ContactRemoved::builder() .jid(jid.parse().expect("test JID")) - .timestamp(ts(1_700_000_200)) + .timestamp(sdk_timestamp(ts(1_700_000_200))) .from_full_sync(false) .build(), ) diff --git a/crates/chat-store/tests/group_membership.rs b/crates/chat-store/tests/group_membership.rs index fb4df6002..25f44f56a 100644 --- a/crates/chat-store/tests/group_membership.rs +++ b/crates/chat-store/tests/group_membership.rs @@ -11,7 +11,7 @@ fn notice(id: &str, index: u32) -> Event { .notification_id(id.to_owned()) .action_index(index) .participant(jid(PEER)) - .timestamp(ts(1_700_000_000)) + .timestamp(sdk_timestamp(ts(1_700_000_000))) .is_lid_addressing_mode(true) .action(Box::new( GroupNotificationAction::add() diff --git a/crates/chat-store/tests/history_sync.rs b/crates/chat-store/tests/history_sync.rs index d6ca095b9..cd9218a31 100644 --- a/crates/chat-store/tests/history_sync.rs +++ b/crates/chat-store/tests/history_sync.rs @@ -74,7 +74,7 @@ async fn history_prefills_live_row_without_overwriting_appstate() { Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new({ let mut constructed: wa::sync_action_value::MuteAction = Default::default(); constructed.muted = Some(false); @@ -86,7 +86,7 @@ async fn history_prefills_live_row_without_overwriting_appstate() { Event::ArchiveUpdate( wacore::types::events::ArchiveUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new({ let mut constructed: wa::sync_action_value::ArchiveChatAction = Default::default(); @@ -137,7 +137,7 @@ async fn missing_preference_options_do_not_unmute_or_unarchive() { Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new(wa::sync_action_value::MuteAction::default())) .from_full_sync(false) .build(), @@ -145,7 +145,7 @@ async fn missing_preference_options_do_not_unmute_or_unarchive() { Event::ArchiveUpdate( wacore::types::events::ArchiveUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new(wa::sync_action_value::ArchiveChatAction::default())) .from_full_sync(false) .build(), diff --git a/crates/chat-store/tests/lid.rs b/crates/chat-store/tests/lid.rs index b5e323b19..0b1e243f5 100644 --- a/crates/chat-store/tests/lid.rs +++ b/crates/chat-store/tests/lid.rs @@ -26,7 +26,7 @@ async fn alias_reconcile_keeps_explicit_unmute_and_unarchive_over_history() { Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_001)) + .timestamp(sdk_timestamp(ts(1_700_000_001))) .action(Box::new({ let mut constructed: wa::sync_action_value::MuteAction = Default::default(); constructed.muted = Some(false); @@ -38,7 +38,7 @@ async fn alias_reconcile_keeps_explicit_unmute_and_unarchive_over_history() { Event::ArchiveUpdate( wacore::types::events::ArchiveUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_001)) + .timestamp(sdk_timestamp(ts(1_700_000_001))) .action(Box::new({ let mut constructed: wa::sync_action_value::ArchiveChatAction = Default::default(); @@ -332,7 +332,7 @@ async fn reconcile_merges_split_pair() { Event::PinUpdate( wacore::types::events::PinUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::PinAction = Default::default(); constructed.pinned = Some(true); diff --git a/crates/chat-store/tests/messages.rs b/crates/chat-store/tests/messages.rs index 6bf3419fb..fcf245a2f 100644 --- a/crates/chat-store/tests/messages.rs +++ b/crates/chat-store/tests/messages.rs @@ -115,7 +115,7 @@ async fn delete_for_me_targets_only_the_named_group_sender() { .maybe_participant_jid(Some(jid(PEER))) .message_id("DELETE-REUSED".into()) .from_me(false) - .timestamp(ts(1_700_000_002)) + .timestamp(sdk_timestamp(ts(1_700_000_002))) .action(Box::new( wa::sync_action_value::DeleteMessageForMeAction::default(), )) diff --git a/crates/chat-store/tests/mute.rs b/crates/chat-store/tests/mute.rs index 19bca206b..97d543011 100644 --- a/crates/chat-store/tests/mute.rs +++ b/crates/chat-store/tests/mute.rs @@ -93,7 +93,7 @@ async fn zero_unmutes_and_malformed_mute_does_not_replace_durable_state() { [Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_000)) + .timestamp(sdk_timestamp(ts(1_700_000_000))) .action(Box::new({ let mut action = wa::sync_action_value::MuteAction::default(); action.muted = Some(true); @@ -233,7 +233,7 @@ async fn late_channel_metadata_rejects_aba_and_same_value_decisions() { [Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(CHANNEL)) - .timestamp(ts(1_700_000_000)) + .timestamp(sdk_timestamp(ts(1_700_000_000))) .action(Box::new({ let mut action = wa::sync_action_value::MuteAction::default(); action.muted = Some(muted); @@ -358,7 +358,7 @@ async fn preference_only_rows_accept_initial_history_unread_and_manual_markers() [Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(chat)) - .timestamp(ts(1_700_000_000)) + .timestamp(sdk_timestamp(ts(1_700_000_000))) .action(Box::new({ let mut action = wa::sync_action_value::MuteAction::default(); action.muted = Some(true); @@ -468,7 +468,7 @@ async fn self_receipts_establish_unread_ownership_before_initial_history() { [Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_000)) + .timestamp(sdk_timestamp(ts(1_700_000_000))) .action(Box::new({ let mut action = wa::sync_action_value::MuteAction::default(); action.muted = Some(true); @@ -544,7 +544,7 @@ async fn late_metadata_does_not_resurrect_a_deleted_revision_zero_channel() { wacore::types::events::DeleteChatUpdate::builder() .jid(jid(CHANNEL)) .delete_media(false) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new(wa::sync_action_value::DeleteChatAction::default())) .from_full_sync(false) .build(), diff --git a/crates/chat-store/tests/offline_receipts.rs b/crates/chat-store/tests/offline_receipts.rs index 32c7c8657..63b231edf 100644 --- a/crates/chat-store/tests/offline_receipts.rs +++ b/crates/chat-store/tests/offline_receipts.rs @@ -170,7 +170,7 @@ async fn clearing_a_chat_discards_unmatched_offline_evidence() { .jid(jid(PEER)) .delete_starred(true) .delete_media(false) - .timestamp(ts(103)) + .timestamp(sdk_timestamp(ts(103))) .action(Box::new(wa::sync_action_value::ClearChatAction::default())) .from_full_sync(false) .build(), @@ -263,7 +263,7 @@ async fn offline_receipts_are_bounded_per_account() { ) .bind::(PEER) .bind::(PEER) - .bind::(wacore::time::now_utc().timestamp_millis() - 1000) + .bind::(wacore::time::now_millis() - 1000) .execute(conn) .map_err(db_err) }) @@ -363,7 +363,7 @@ fn clear( .jid(jid(PEER)) .delete_starred(delete_starred) .delete_media(false) - .timestamp(ts(103)) + .timestamp(sdk_timestamp(ts(103))) .action(Box::new(action)) .from_full_sync(false) .build(), @@ -378,7 +378,7 @@ async fn ranged_clear_and_delete_preserve_receipts_for_surviving_messages_in_the wacore::types::events::DeleteChatUpdate::builder() .jid(jid(PEER)) .delete_media(false) - .timestamp(ts(103)) + .timestamp(sdk_timestamp(ts(103))) .action(Box::new(delete)) .from_full_sync(false) .build(), @@ -420,7 +420,7 @@ async fn clear_preserving_starred_messages_keeps_their_pending_receipts() { .chat_jid(jid(PEER)) .message_id("STARRED-SURVIVOR".into()) .from_me(true) - .timestamp(ts(101)) + .timestamp(sdk_timestamp(ts(101))) .action(Box::new(action)) .from_full_sync(false) .build(), diff --git a/crates/chat-store/tests/operation_acks.rs b/crates/chat-store/tests/operation_acks.rs index e3b829ea3..59567e3e7 100644 --- a/crates/chat-store/tests/operation_acks.rs +++ b/crates/chat-store/tests/operation_acks.rs @@ -264,7 +264,7 @@ async fn chatless_ack_collision_between_a_row_and_another_chats_operation_is_ref .id("CHATLESS-COLLISION".to_string()) .class("message".to_string()) .maybe_error(rejected.then(|| "403".to_string())) - .timestamp(ts(1_700_000_042)) + .timestamp(sdk_timestamp(ts(1_700_000_042))) .build(); feed(&chat_store, [Event::ServerAck(answer)]).await; let row = chat_store @@ -292,7 +292,7 @@ async fn distinct_early_ack_answers_keep_arrival_order_and_timestamp_corrections .class("message".to_string()) .from(chat.clone()) .maybe_error(error.map(str::to_owned)) - .timestamp(ts(1_700_000_010 + i as i64)) + .timestamp(sdk_timestamp(ts(1_700_000_010 + i as i64))) .build(), ) }) diff --git a/crates/chat-store/tests/outgoing.rs b/crates/chat-store/tests/outgoing.rs index 6c0ca2783..075b0ee4c 100644 --- a/crates/chat-store/tests/outgoing.rs +++ b/crates/chat-store/tests/outgoing.rs @@ -364,7 +364,7 @@ async fn server_nack_does_not_reconcile_timestamp() { .id("OUT-NACK-CLOCK".to_string()) .class("message".to_string()) .from(chat.clone()) - .timestamp(ts(1_700_000_500)) + .timestamp(sdk_timestamp(ts(1_700_000_500))) .error("479".to_string()) .build(), )], @@ -411,7 +411,7 @@ async fn server_ack_disambiguates_reused_message_id_by_chat() { ServerAck::builder() .id(shared_id.to_string()) .class("message".to_string()) - .timestamp(server_timestamp) + .timestamp(sdk_timestamp(server_timestamp)) .build(), )], ) diff --git a/crates/chat-store/tests/pagination.rs b/crates/chat-store/tests/pagination.rs index 578511f0d..0de88511c 100644 --- a/crates/chat-store/tests/pagination.rs +++ b/crates/chat-store/tests/pagination.rs @@ -563,7 +563,7 @@ async fn chat_list_pages_across_the_pinned_boundary() { events.push(Event::PinUpdate( wacore::types::events::PinUpdate::builder() .jid(jid(peer)) - .timestamp(ts(1_700_000_500 + i as i64)) + .timestamp(sdk_timestamp(ts(1_700_000_500 + i as i64))) .action(Box::new({ let mut constructed: wa::sync_action_value::PinAction = Default::default(); constructed.pinned = Some(true); diff --git a/crates/chat-store/tests/read_state.rs b/crates/chat-store/tests/read_state.rs index 37151aab3..8cf300e1f 100644 --- a/crates/chat-store/tests/read_state.rs +++ b/crates/chat-store/tests/read_state.rs @@ -40,7 +40,7 @@ async fn mark_chat_as_read_resets_unread_count() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -119,7 +119,7 @@ async fn delete_for_me_cleans_satellites_and_recomputes_preview() { ..Default::default() }) .message_ids(vec!["MSG-D".into()]) - .timestamp(ts(1_700_000_110)) + .timestamp(sdk_timestamp(ts(1_700_000_110))) .r#type(ReceiptType::Read) .offline(false) .build(), @@ -166,7 +166,7 @@ async fn forever_mute_is_not_reported_as_unmuted() { Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) // muted with no end timestamp = muted forever .action(Box::new({ let mut constructed: wa::sync_action_value::MuteAction = Default::default(); @@ -183,7 +183,7 @@ async fn forever_mute_is_not_reported_as_unmuted() { let chats = chat_store.chats(false, 10).await.unwrap(); let muted_until = chats[0].muted_until.expect("forever mute must be Some"); - assert!(muted_until > wacore::time::now_utc()); + assert!(muted_until > oxidezap_core::time::now_utc()); assert_eq!(muted_until, chrono::DateTime::::MAX_UTC); } @@ -208,7 +208,7 @@ async fn clear_chat_reflects_surviving_starred_messages() { .chat_jid(chat.clone()) .message_id("MSG-S1".to_string()) .from_me(false) - .timestamp(ts(1_700_000_200)) + .timestamp(sdk_timestamp(ts(1_700_000_200))) .action(Box::new({ let mut constructed: wa::sync_action_value::StarAction = Default::default(); constructed.starred = Some(true); @@ -222,7 +222,7 @@ async fn clear_chat_reflects_surviving_starred_messages() { .jid(chat.clone()) .delete_starred(false) .delete_media(false) - .timestamp(ts(1_700_000_300)) + .timestamp(sdk_timestamp(ts(1_700_000_300))) .action(Box::new(wa::sync_action_value::ClearChatAction::default())) .from_full_sync(false) .build(), @@ -271,7 +271,7 @@ async fn mark_read_range_preserves_newer_unread() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -310,7 +310,7 @@ async fn the_unread_tail_does_not_repeat_on_an_older_page() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -367,7 +367,7 @@ async fn ranged_clear_and_delete_keep_newer_messages() { .jid(chat.clone()) .delete_starred(true) .delete_media(false) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::ClearChatAction = Default::default(); @@ -394,7 +394,7 @@ async fn ranged_clear_and_delete_keep_newer_messages() { wacore::types::events::DeleteChatUpdate::builder() .jid(chat.clone()) .delete_media(false) - .timestamp(ts(1_700_000_060)) + .timestamp(sdk_timestamp(ts(1_700_000_060))) .action(Box::new({ let mut constructed: wa::sync_action_value::DeleteChatAction = Default::default(); @@ -416,7 +416,7 @@ async fn ranged_clear_and_delete_keep_newer_messages() { wacore::types::events::DeleteChatUpdate::builder() .jid(chat.clone()) .delete_media(false) - .timestamp(ts(1_700_000_070)) + .timestamp(sdk_timestamp(ts(1_700_000_070))) .action(Box::new(wa::sync_action_value::DeleteChatAction::default())) .from_full_sync(false) .build(), @@ -433,7 +433,7 @@ async fn range_boundary_covers_the_whole_wire_second() { // 500 ms into the boundary second: the wire range (whole seconds) covers // it, so a mark-read up to that second must clear it. let mut info = incoming_info(PEER, PEER, "MSG-SUB", 1_700_000_000); - info.timestamp = Utc.timestamp_opt(1_700_000_000, 500_000_000).unwrap(); + info.timestamp = wacore::Timestamp::from_millis(1_700_000_000_500).unwrap(); feed( &chat_store, [message_event(wa::Message::text("sub-second"), info)], @@ -446,7 +446,7 @@ async fn range_boundary_covers_the_whole_wire_second() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_001)) + .timestamp(sdk_timestamp(ts(1_700_000_001))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -503,7 +503,7 @@ async fn keyed_range_spares_unlisted_same_second_siblings() { .jid(chat.clone()) .delete_starred(true) .delete_media(false) - .timestamp(ts(1_700_000_001)) + .timestamp(sdk_timestamp(ts(1_700_000_001))) .action(Box::new({ let mut constructed: wa::sync_action_value::ClearChatAction = Default::default(); @@ -561,7 +561,7 @@ async fn ranged_clear_keeps_unread_survivors_counted() { .jid(chat.clone()) .delete_starred(true) .delete_media(false) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::ClearChatAction = Default::default(); @@ -731,7 +731,7 @@ async fn stale_ranged_mark_read_respects_the_read_cursor() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -788,7 +788,7 @@ async fn keyed_mark_read_spares_unlisted_same_second_sibling() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_001)) + .timestamp(sdk_timestamp(ts(1_700_000_001))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -815,7 +815,7 @@ async fn late_materialized_old_message_does_not_badge_after_read() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -951,7 +951,7 @@ async fn keyed_read_covers_a_message_that_materializes_later() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_001)) + .timestamp(sdk_timestamp(ts(1_700_000_001))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); @@ -1002,7 +1002,7 @@ async fn wire_indefinite_mute_value_reads_as_forever() { Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) // The wire's indefinite-mute sentinel (what the library's // own mute_chat() sends). .action(Box::new({ @@ -1060,7 +1060,7 @@ async fn notification_policy_is_fail_closed_and_follows_mute_and_archive() { [Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(GROUP)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new({ let mut constructed: wa::sync_action_value::MuteAction = Default::default(); constructed.muted = Some(true); @@ -1086,7 +1086,7 @@ async fn notification_policy_is_fail_closed_and_follows_mute_and_archive() { [Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(GROUP)) - .timestamp(ts(1_700_000_200)) + .timestamp(sdk_timestamp(ts(1_700_000_200))) .action(Box::new({ let mut constructed: wa::sync_action_value::MuteAction = Default::default(); constructed.muted = Some(false); @@ -1112,7 +1112,7 @@ async fn notification_policy_is_fail_closed_and_follows_mute_and_archive() { [Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(GROUP)) - .timestamp(ts(1_700_000_250)) + .timestamp(sdk_timestamp(ts(1_700_000_250))) .action(Box::new({ let mut constructed: wa::sync_action_value::MuteAction = Default::default(); constructed.muted = Some(true); @@ -1137,7 +1137,7 @@ async fn notification_policy_is_fail_closed_and_follows_mute_and_archive() { [Event::ArchiveUpdate( wacore::types::events::ArchiveUpdate::builder() .jid(jid(GROUP)) - .timestamp(ts(1_700_000_300)) + .timestamp(sdk_timestamp(ts(1_700_000_300))) .action(Box::new({ let mut constructed: wa::sync_action_value::ArchiveChatAction = Default::default(); @@ -1172,7 +1172,7 @@ async fn notification_policy_checks_both_unmerged_peer_aliases() { Event::MuteUpdate( wacore::types::events::MuteUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::MuteAction = Default::default(); constructed.muted = Some(true); @@ -1289,7 +1289,7 @@ async fn notification_read_query_respects_aliases_and_keyed_boundary_seconds() { [Event::MarkChatAsReadUpdate( wacore::types::events::MarkChatAsReadUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new({ let mut constructed: wa::sync_action_value::MarkChatAsReadAction = Default::default(); diff --git a/crates/chat-store/tests/receipts.rs b/crates/chat-store/tests/receipts.rs index a481ae75e..84418797b 100644 --- a/crates/chat-store/tests/receipts.rs +++ b/crates/chat-store/tests/receipts.rs @@ -607,7 +607,7 @@ async fn a_receipt_arriving_after_a_delete_does_not_resurrect_it() { .jid(peer.clone()) .delete_starred(true) .delete_media(false) - .timestamp(ts(1_700_000_300)) + .timestamp(sdk_timestamp(ts(1_700_000_300))) .action(Box::new({ let mut constructed: wa::sync_action_value::ClearChatAction = Default::default(); @@ -753,7 +753,7 @@ async fn companion_sender_push_name_lands_on_the_bare_contact() { ..Default::default() }, id: "IN-AD-2".into(), - timestamp: ts(1_700_000_000), + timestamp: sdk_timestamp(ts(1_700_000_000)), ..Default::default() }; info.push_name = "Alice Example".into(); diff --git a/crates/chat-store/tests/regression_194.rs b/crates/chat-store/tests/regression_194.rs index a6099b0fd..52c8b6870 100644 --- a/crates/chat-store/tests/regression_194.rs +++ b/crates/chat-store/tests/regression_194.rs @@ -1119,7 +1119,7 @@ async fn delete_for_me_normalizes_device_qualified_participants_without_hitting_ .maybe_participant_jid(Some(jid(&device_sender))) .message_id(id.into()) .from_me(false) - .timestamp(ts(1_700_000_020)) + .timestamp(sdk_timestamp(ts(1_700_000_020))) .action(Box::new( wa::sync_action_value::DeleteMessageForMeAction::default(), )) diff --git a/crates/chat-store/tests/regression_212.rs b/crates/chat-store/tests/regression_212.rs index 45dc48e4c..21168a0e7 100644 --- a/crates/chat-store/tests/regression_212.rs +++ b/crates/chat-store/tests/regression_212.rs @@ -466,7 +466,7 @@ async fn marked_unread_history_keeps_marker_through_seed() { #[tokio::test] async fn future_dated_history_row_does_not_reopen_phone_read_chat() { let (store, chat_store) = test_store().await; - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; feed( &chat_store, [history_sync_event({ @@ -623,7 +623,7 @@ async fn upgrade_repair_merging_incoming_duplicates_without_marker_keeps_zero() #[tokio::test] async fn oversized_future_snapshot_keeps_phone_read_zero() { let (store, chat_store) = test_store().await; - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; let messages: Vec = (0..300) .map(|n| { let mut constructed: wa::HistorySyncMsg = Default::default(); @@ -691,7 +691,7 @@ async fn seed_does_not_evict_existing_keyed_coverage() { .unwrap(); // Another phone-read snapshot with one future row: no room beside the // kept ids, so the seed refuses rather than evicting them. - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; feed( &chat_store, [history_sync_event({ @@ -732,7 +732,7 @@ async fn seed_does_not_evict_existing_keyed_coverage() { #[tokio::test] async fn sweep_covers_future_rows_for_later_merges() { let (store, chat_store) = test_store().await; - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; feed( &chat_store, [history_sync_event({ @@ -786,7 +786,7 @@ async fn sweep_covers_future_rows_for_later_merges() { let watermark = read_boundary_ms(&store, PEER).await; assert!(watermark > 0, "the sweep backfills a baseline"); assert!( - watermark <= wacore::time::now_utc().timestamp_millis(), + watermark <= wacore::time::now_millis(), "the baseline never outruns the local clock" ); assert!( @@ -829,7 +829,7 @@ async fn sweep_covers_future_rows_for_later_merges() { #[tokio::test] async fn oversized_legacy_snapshot_seeds_nothing_at_all() { let (store, chat_store) = test_store().await; - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; let messages: Vec = (0..300) .map(|n| { let mut constructed: wa::HistorySyncMsg = Default::default(); @@ -934,7 +934,7 @@ async fn seed_counts_capacity_after_pruning_implied_ids() { .unwrap(); // One more future row: every kept id falls below the new frontier, so // the advance prunes them and room remains for the new coverage. - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; feed( &chat_store, [history_sync_event({ @@ -975,7 +975,7 @@ async fn seed_counts_capacity_after_pruning_implied_ids() { #[tokio::test] async fn seed_frees_only_ids_without_a_newer_row() { let (store, chat_store) = test_store().await; - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; // One id in two rows straddling any frontier: an old copy and a future // one, side by side before any mapping proves them one message. feed( @@ -1086,7 +1086,7 @@ async fn seed_frees_only_ids_without_a_newer_row() { #[tokio::test] async fn outgoing_twins_do_not_occupy_read_coverage_room() { let (store, chat_store) = test_store().await; - let future_secs = (wacore::time::now_utc().timestamp_millis() / 1000) as u64 + 3_600; + let future_secs = (wacore::time::now_millis() / 1000) as u64 + 3_600; // One id in two directions: an incoming copy below any frontier and an // own copy above it. Coverage only ever badges incoming traffic, so the // outgoing twin must not keep the id occupying room. @@ -1291,7 +1291,7 @@ async fn deleted_lid_full_repair_merges_duplicate_without_losing_phone_read_coun #[tokio::test] async fn local_revoke_placeholders_do_not_exhaust_history_read_coverage() { let (store, chat_store) = test_store().await; - let future = wacore::time::now_utc() + chrono::Duration::hours(1); + let future = oxidezap_core::time::now_utc() + chrono::Duration::hours(1); for n in 0..257 { chat_store .record_revoke_target( diff --git a/crates/chat-store/tests/regression_232.rs b/crates/chat-store/tests/regression_232.rs index 131b50eae..c8ca318e7 100644 --- a/crates/chat-store/tests/regression_232.rs +++ b/crates/chat-store/tests/regression_232.rs @@ -66,7 +66,7 @@ async fn rejected_inbound_preserves_preceding_local_writes_and_causal_order() { handler.handle_event(Arc::new(Event::PinUpdate( PinUpdate::builder() .jid(chat.clone()) - .timestamp(ts(1_700_000_040)) + .timestamp(sdk_timestamp(ts(1_700_000_040))) .action(Box::new({ let mut constructed: wa::sync_action_value::PinAction = Default::default(); constructed.pinned = Some(true); @@ -78,7 +78,7 @@ async fn rejected_inbound_preserves_preceding_local_writes_and_causal_order() { handler.handle_event(Arc::new(Event::ContactUpdate( ContactUpdate::builder() .jid(chat.clone()) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::ContactAction = Default::default(); constructed.full_name = Some("Synthetic Contact".into()); @@ -446,7 +446,7 @@ async fn ordinary_event_rollback_retains_mixed_writes_and_blocks_later_batches() handler.handle_event(Arc::new(Event::PinUpdate( PinUpdate::builder() .jid(chat.clone()) - .timestamp(ts(1_700_000_040)) + .timestamp(sdk_timestamp(ts(1_700_000_040))) .action(Box::new({ let mut constructed: wa::sync_action_value::PinAction = Default::default(); constructed.pinned = Some(true); @@ -458,7 +458,7 @@ async fn ordinary_event_rollback_retains_mixed_writes_and_blocks_later_batches() handler.handle_event(Arc::new(Event::ContactUpdate( ContactUpdate::builder() .jid(chat.clone()) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::ContactAction = Default::default(); constructed.full_name = Some("Synthetic Retained Contact".into()); diff --git a/crates/chat-store/tests/scoped_activity.rs b/crates/chat-store/tests/scoped_activity.rs index 9e456b5c4..4fea6e442 100644 --- a/crates/chat-store/tests/scoped_activity.rs +++ b/crates/chat-store/tests/scoped_activity.rs @@ -32,7 +32,7 @@ async fn send_ack_timestamp_and_delivery_only_invalidate_the_affected_chat() { let Event::ServerAck(mut sent) = ack("SCOPED-SEND", jid(PEER)) else { unreachable!() }; - sent.timestamp = Some(ts(101)); + sent.timestamp = Some(sdk_timestamp(ts(101))); feed(&store, [Event::ServerAck(sent)]).await; drain_scoped(&mut changes); assert_eq!( diff --git a/crates/chat-store/tests/shared_history.rs b/crates/chat-store/tests/shared_history.rs index 7d0e6c3f8..7078c03f4 100644 --- a/crates/chat-store/tests/shared_history.rs +++ b/crates/chat-store/tests/shared_history.rs @@ -558,7 +558,7 @@ async fn review_245_deleted_pending_import(delete: bool) { wacore::types::events::DeleteChatUpdate::builder() .jid(jid(GROUP)) .delete_media(false) - .timestamp(ts(AT + 1)) + .timestamp(sdk_timestamp(ts(AT + 1))) .action(Box::new(wa::sync_action_value::DeleteChatAction::default())) .from_full_sync(false) .build(), @@ -569,7 +569,7 @@ async fn review_245_deleted_pending_import(delete: bool) { .jid(jid(GROUP)) .delete_starred(false) .delete_media(false) - .timestamp(ts(AT + 1)) + .timestamp(sdk_timestamp(ts(AT + 1))) .action(Box::new(wa::sync_action_value::ClearChatAction::default())) .from_full_sync(false) .build(), @@ -766,7 +766,7 @@ async fn review_245_ranged_clear_retires_only_covered_attachment_keys() { .jid(jid(GROUP)) .delete_starred(false) .delete_media(false) - .timestamp(ts(AT + 2)) + .timestamp(sdk_timestamp(ts(AT + 2))) .action(Box::new(action)) .from_full_sync(false) .build(), diff --git a/crates/chat-store/tests/status_watch.rs b/crates/chat-store/tests/status_watch.rs index 235603c34..218d764d7 100644 --- a/crates/chat-store/tests/status_watch.rs +++ b/crates/chat-store/tests/status_watch.rs @@ -72,7 +72,7 @@ async fn a_view_moves_only_incoming_rows_in_the_chat_it_names() { ..Default::default() }, id: "MINE".into(), - timestamp: ts(1_700_000_000), + timestamp: sdk_timestamp(ts(1_700_000_000)), ..Default::default() }; feed( @@ -202,7 +202,7 @@ async fn a_redelivered_pin_buys_no_reload() { Event::PinUpdate( wacore::types::events::PinUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(ts_secs)) + .timestamp(sdk_timestamp(ts(ts_secs))) .action(Box::new({ let mut constructed: wa::sync_action_value::PinAction = Default::default(); constructed.pinned = Some(true); diff --git a/crates/chat-store/tests/writer.rs b/crates/chat-store/tests/writer.rs index f2acef5af..1d2d98b84 100644 --- a/crates/chat-store/tests/writer.rs +++ b/crates/chat-store/tests/writer.rs @@ -85,7 +85,7 @@ async fn a_pin_names_its_chat_instead_of_the_whole_list() { [Event::PinUpdate( wacore::types::events::PinUpdate::builder() .jid(jid(PEER)) - .timestamp(ts(1_700_000_050)) + .timestamp(sdk_timestamp(ts(1_700_000_050))) .action(Box::new({ let mut constructed: wa::sync_action_value::PinAction = Default::default(); constructed.pinned = Some(true); @@ -902,7 +902,7 @@ async fn a_metadata_answer_for_a_deleted_chat_writes_nothing() { DeleteChatUpdate::builder() .jid(group.clone()) .delete_media(false) - .timestamp(ts(1_700_000_100)) + .timestamp(sdk_timestamp(ts(1_700_000_100))) .action(Box::new(wa::sync_action_value::DeleteChatAction::default())) .from_full_sync(false) .build(), diff --git a/crates/core/src/call.rs b/crates/core/src/call.rs index d050ae068..5e94be4b5 100644 --- a/crates/core/src/call.rs +++ b/crates/core/src/call.rs @@ -39,7 +39,7 @@ impl OutgoingCall { recipient_jid, is_video, state: OutgoingCallState::Initiating, - initiated_at: wacore::time::now_utc(), + initiated_at: crate::time::now_utc(), } } @@ -99,7 +99,9 @@ impl IncomingCall { caller_jid, is_video, is_offline: offer.offline, - received_at: offer.timestamp.unwrap_or_else(wacore::time::now_utc), + received_at: crate::time::from_sdk( + offer.timestamp.unwrap_or_else(wacore::time::now_utc), + ), } } diff --git a/crates/core/src/calls.rs b/crates/core/src/calls.rs index 15858e369..b5c2acef4 100644 --- a/crates/core/src/calls.rs +++ b/crates/core/src/calls.rs @@ -60,7 +60,7 @@ impl ActiveCall { /// but a clock that steps backwards would otherwise render a negative /// duration. pub fn elapsed(&self) -> chrono::Duration { - (wacore::time::now_utc() - self.started_at).max(chrono::Duration::zero()) + (crate::time::now_utc() - self.started_at).max(chrono::Duration::zero()) } /// `m:ss`, growing an hour field only once there is one. @@ -553,7 +553,7 @@ impl CallState { ..CallVideo::default() }, is_outgoing: matches!(stage, Stage::Outgoing(_)), - started_at: wacore::time::now_utc(), + started_at: crate::time::now_utc(), muted: false, }; self.stage = Some(Stage::Active(active)); @@ -601,7 +601,7 @@ impl CallState { }, // Answering an offer: they called us. is_outgoing: false, - started_at: wacore::time::now_utc(), + started_at: crate::time::now_utc(), muted: false, })); } @@ -1295,7 +1295,7 @@ mod tests { #[test] fn incoming_calls_keep_the_protocol_timestamp() { let mut wire = offer("OLD"); - wire.timestamp = chrono::DateTime::from_timestamp(1_700_000_000, 0); + wire.timestamp = wacore::Timestamp::from_secs(1_700_000_000); let call = IncomingCall::new( "OLD", "Example".into(), @@ -1303,14 +1303,17 @@ mod tests { false, &wire, ); - assert_eq!(Some(call.received_at), wire.timestamp); + assert_eq!( + Some(call.received_at), + wire.timestamp.map(crate::time::from_sdk) + ); } #[test] fn incoming_call_without_server_time_uses_local_receipt_time() { let mut wire = offer("NO-TIME"); wire.timestamp = None; - let before = wacore::time::now_utc(); + let before = crate::time::now_utc(); let call = IncomingCall::new( "NO-TIME", "Example".into(), @@ -1318,7 +1321,7 @@ mod tests { false, &wire, ); - let after = wacore::time::now_utc(); + let after = crate::time::now_utc(); assert!(call.received_at >= before && call.received_at <= after); } diff --git a/crates/core/src/chat/message.rs b/crates/core/src/chat/message.rs index f31cdfe6f..62fd23d49 100644 --- a/crates/core/src/chat/message.rs +++ b/crates/core/src/chat/message.rs @@ -120,7 +120,7 @@ impl ChatMessage { sender_name: None, content, is_text: true, - timestamp: wacore::time::now_utc(), + timestamp: crate::time::now_utc(), is_from_me: true, is_read: false, media: None, @@ -153,7 +153,7 @@ impl ChatMessage { sender_name: None, content, is_text: true, - timestamp: wacore::time::now_utc(), + timestamp: crate::time::now_utc(), is_from_me: false, is_read: false, media: None, diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index ac2245741..21cab392b 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -18,6 +18,7 @@ pub mod base64; /// asked for, so nothing an embedder links carries it. #[cfg(any(test, feature = "fixtures"))] pub mod fixtures; +pub mod time; mod account; mod app_state; diff --git a/crates/core/src/presence.rs b/crates/core/src/presence.rs index f0ce0fc63..518d762d1 100644 --- a/crates/core/src/presence.rs +++ b/crates/core/src/presence.rs @@ -237,7 +237,7 @@ impl PresenceRegistry { self.typing .entry(chat) .or_default() - .set(sender, name, kind, wacore::time::now_utc()); + .set(sender, name, kind, crate::time::now_utc()); } /// Record that `sender` stopped. @@ -268,7 +268,7 @@ impl PresenceRegistry { pub fn typing(&self, chat: &str) -> Option { self.typing .get(chat) - .and_then(|entry| entry.summary(wacore::time::now_utc())) + .and_then(|entry| entry.summary(crate::time::now_utc())) } /// Whether anyone at all is typing, so a render pass can skip the work. @@ -277,7 +277,7 @@ impl PresenceRegistry { /// throwing them away: this exists to *avoid* work, and `summary` allocates /// a vector and clones a JID and a name for every chat it is asked about. pub fn has_typing(&self) -> bool { - let now = wacore::time::now_utc(); + let now = crate::time::now_utc(); self.typing.values().any(|entry| entry.has_live(now)) } @@ -287,7 +287,7 @@ impl PresenceRegistry { /// it keeps the map from growing with people who typed once and left. /// Returns whether anything was removed, so the caller can skip a redraw. pub fn prune(&mut self) -> bool { - let now = wacore::time::now_utc(); + let now = crate::time::now_utc(); // Typists, not chats. Counting chats missed the case that matters in // a group: one of two typists stops, the chat is still typing, and the // caller skipped the redraw that would have dropped their name. diff --git a/crates/core/src/status.rs b/crates/core/src/status.rs index ee2c53b9d..78b3a69de 100644 --- a/crates/core/src/status.rs +++ b/crates/core/src/status.rs @@ -68,7 +68,7 @@ impl StatusFeed { /// rebuild: one pass, one small vector per author, and no message is /// copied. pub fn from_chat(chat: &Chat) -> Self { - Self::from_chat_at(chat, wacore::time::now_utc()) + Self::from_chat_at(chat, crate::time::now_utc()) } /// The feed as it stood at `now`. diff --git a/crates/core/src/time.rs b/crates/core/src/time.rs new file mode 100644 index 000000000..f9cd05c41 --- /dev/null +++ b/crates/core/src/time.rs @@ -0,0 +1,38 @@ +//! Conversions at the SDK boundary. Client IPC and storage retain their existing UTC types. + +use chrono::{DateTime, Utc}; +use wacore::Timestamp; + +/// Convert an SDK timestamp without changing the client's UTC representation. +pub fn from_sdk(timestamp: Timestamp) -> DateTime { + DateTime::from_timestamp_millis(timestamp.as_millis()) + .expect("SDK timestamps fit the UTC calendar range") +} + +/// Read the SDK wall clock for client-owned timestamps. +pub fn now_utc() -> DateTime { + from_sdk(wacore::time::now_utc()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn preserves_signed_epoch_milliseconds_and_utc() { + for millis in [ + Timestamp::MIN_MILLIS, + -1001, + -1, + 0, + 1, + 1_700_000_000_123, + Timestamp::MAX_MILLIS, + ] { + let sdk = Timestamp::from_millis(millis).unwrap(); + let utc = from_sdk(sdk); + assert_eq!(utc.timestamp_millis(), millis); + assert_eq!(utc.timezone(), Utc); + } + } +} diff --git a/crates/daemon/src/account/retirement.rs b/crates/daemon/src/account/retirement.rs index 99e135a34..110bd9c18 100644 --- a/crates/daemon/src/account/retirement.rs +++ b/crates/daemon/src/account/retirement.rs @@ -403,7 +403,7 @@ mod tests { &peer, "RETAINED", &Default::default(), - wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) .unwrap(); history.flush().await.unwrap(); diff --git a/crates/daemon/src/session_bridge/call_log.rs b/crates/daemon/src/session_bridge/call_log.rs index bfc5d144b..f8193f0ae 100644 --- a/crates/daemon/src/session_bridge/call_log.rs +++ b/crates/daemon/src/session_bridge/call_log.rs @@ -198,7 +198,7 @@ mod tests { caller_jid: "559900000001@s.whatsapp.net".to_string(), is_video: false, is_offline: false, - received_at: wacore::time::now_utc(), + received_at: oxidezap_core::time::now_utc(), }) } diff --git a/crates/daemon/src/session_bridge/mod.rs b/crates/daemon/src/session_bridge/mod.rs index 74f38932f..7b21b26c1 100644 --- a/crates/daemon/src/session_bridge/mod.rs +++ b/crates/daemon/src/session_bridge/mod.rs @@ -783,7 +783,7 @@ impl Bridge { /// Refresh time-dependent attention and wait for its next possible change. /// Video frames do not reset this timer or scan the conversation list. async fn wait_for_mute_expiry(hub: Arc) { - let now_ms = wacore::time::now_utc().timestamp_millis(); + let now_ms = wacore::time::now_millis(); hub.refresh_tray(); match hub.next_mute_expiry(now_ms) { Some(until) => { diff --git a/crates/daemon/src/session_bridge/tests.rs b/crates/daemon/src/session_bridge/tests.rs index 519d0508e..8dc2379d3 100644 --- a/crates/daemon/src/session_bridge/tests.rs +++ b/crates/daemon/src/session_bridge/tests.rs @@ -996,7 +996,7 @@ fn first_live_message_carries_mute_to_tray_before_chat_hydration() { bridge.observe(event); let summary = bridge.hub.chat(jid).unwrap(); assert_eq!(summary.unread, 1); - assert!(summary.is_muted(wacore::time::now_utc().timestamp_millis())); + assert!(summary.is_muted(wacore::time::now_millis())); assert_eq!(bridge.hub.watch_tray().borrow().unread, 0); } diff --git a/crates/daemon/src/session_bridge/wire_events.rs b/crates/daemon/src/session_bridge/wire_events.rs index 8c6bf6e54..150c4e5d1 100644 --- a/crates/daemon/src/session_bridge/wire_events.rs +++ b/crates/daemon/src/session_bridge/wire_events.rs @@ -75,7 +75,7 @@ pub(crate) fn connection_status_of(state: &ConnectionState, hub: &StateHub) -> C /// A chat summary as the protocol's chat. Archive state still requires a full chat. pub(crate) fn chat_summary_to_dto(summary: ChatSummary) -> ChatDto { - let is_muted = summary.is_muted(wacore::time::now_utc().timestamp_millis()); + let is_muted = summary.is_muted(wacore::time::now_millis()); let is_group = summary.jid.parse::().is_ok_and(|jid| jid.is_group()); ChatDto { jid: summary.jid, @@ -101,7 +101,7 @@ pub(crate) fn chat_to_dto(chat: oxidezap_core::Chat) -> ChatDto { is_pinned: chat.pinned_at.is_some(), is_muted: chat .muted_until - .is_some_and(|until| until > wacore::time::now_utc()), + .is_some_and(|until| until > oxidezap_core::time::now_utc()), is_archived: chat.archived, last_message_ts: chat.last_message_time.map(|t| t.timestamp_millis()), last_message_preview: chat.last_message, diff --git a/crates/daemon/src/state/mod.rs b/crates/daemon/src/state/mod.rs index a767ecc04..e2941919a 100644 --- a/crates/daemon/src/state/mod.rs +++ b/crates/daemon/src/state/mod.rs @@ -994,7 +994,7 @@ mod tests { summary.clone(), ))); assert_eq!(tray.borrow_and_update().unread, 7); - let until = wacore::time::now_utc().timestamp_millis() + 30; + let until = wacore::time::now_millis() + 30; summary.muted_until_ms = Some(until); hub.apply(Change::from_store(DaemonEvent::ChatUpdated( summary.clone(), diff --git a/crates/daemon/src/state/store.rs b/crates/daemon/src/state/store.rs index 7b2f6416f..0ef4fd382 100644 --- a/crates/daemon/src/state/store.rs +++ b/crates/daemon/src/state/store.rs @@ -364,7 +364,7 @@ impl StateStore { if only_for.is_some_and(|asked| asked != inner.account_generation) { return None; } - inner.advance_attention(wacore::time::now_utc().timestamp_millis()); + inner.advance_attention(wacore::time::now_millis()); inner.version = inner.version.next(); match &event { @@ -578,7 +578,7 @@ impl Inner { } fn tray_state(&mut self) -> TrayState { - self.advance_attention(wacore::time::now_utc().timestamp_millis()); + self.advance_attention(wacore::time::now_millis()); TrayState { connected: self.connection.is_connected(), unread: self.attention.total.min(u128::from(u32::MAX)) as u32, @@ -601,7 +601,7 @@ mod tests { .unwrap_or_else(|_| "0".into()) .parse() .unwrap(); - let until = wacore::time::now_utc().timestamp_millis() + 3_600_000; + let until = wacore::time::now_millis() + 3_600_000; let make_chat = |i: usize, unread| { let mut change = chat(&format!("synthetic-{i}@s.whatsapp.net"), unread); if mute_every > 0 @@ -624,7 +624,7 @@ mod tests { .unwrap(); assert_eq!(published.tray.unread, expected); store.refresh_tray(|tray| assert_eq!(tray.unread, expected)); - let deadline = store.next_mute_expiry(wacore::time::now_utc().timestamp_millis()); + let deadline = store.next_mute_expiry(wacore::time::now_millis()); assert_eq!(deadline, (mute_every > 0).then_some(until)); let _ = std::hint::black_box(published); } @@ -681,7 +681,7 @@ mod tests { #[test] fn incremental_attention_matches_scan_through_updates_expiry_and_clock_reversal() { let store = store(); - let now = wacore::time::now_utc().timestamp_millis(); + let now = wacore::time::now_millis(); let forever = chrono::DateTime::::MAX_UTC.timestamp_millis(); let mut seed = 17u64; for step in 0..2000 { @@ -727,7 +727,7 @@ mod tests { #[test] fn attention_recovers_after_saturation_and_removes_shared_deadlines() { let store = store(); - let until = wacore::time::now_utc().timestamp_millis() + 60_000; + let until = wacore::time::now_millis() + 60_000; for jid in ["a", "b", "c"] { let mut change = chat(jid, u32::MAX); if let DaemonEvent::ChatUpdated(summary) = &mut change.event { diff --git a/crates/gui/src/app/calls_ctl.rs b/crates/gui/src/app/calls_ctl.rs index c123f909b..df786d766 100644 --- a/crates/gui/src/app/calls_ctl.rs +++ b/crates/gui/src/app/calls_ctl.rs @@ -1676,7 +1676,7 @@ mod call_alert_review_regressions { caller_jid: "999000@s.whatsapp.net".into(), is_video: false, is_offline: false, - received_at: wacore::time::now_utc(), + received_at: oxidezap_core::time::now_utc(), }; assert!(calls.post_alert_notification(&key, &offer, cx)); calls.stop_alert(false, cx); @@ -1699,7 +1699,7 @@ mod call_alert_review_regressions { caller_jid: "999000@s.whatsapp.net".into(), is_video: false, is_offline: false, - received_at: wacore::time::now_utc(), + received_at: oxidezap_core::time::now_utc(), }); assert!(calls.alerts.follow(Some(account), &calls.state)); calls.silence_alerts(cx); @@ -1854,7 +1854,7 @@ mod call_control_tests { caller_jid: "999001@s.whatsapp.net".into(), is_video: true, is_offline: false, - received_at: wacore::time::now_utc(), + received_at: oxidezap_core::time::now_utc(), }); let image = Arc::new(RenderImage::new(smallvec::SmallVec::from_elem( image::Frame::new(image::RgbaImage::new(1, 1)), @@ -1895,7 +1895,7 @@ mod call_control_tests { caller_jid: "999000@s.whatsapp.net".into(), is_video: false, is_offline: false, - received_at: wacore::time::now_utc(), + received_at: oxidezap_core::time::now_utc(), }); }); app.hang_up(cx); diff --git a/crates/gui/src/app/calls_ctl/alerts.rs b/crates/gui/src/app/calls_ctl/alerts.rs index 417c0c50b..9f68feb91 100644 --- a/crates/gui/src/app/calls_ctl/alerts.rs +++ b/crates/gui/src/app/calls_ctl/alerts.rs @@ -137,7 +137,7 @@ mod call_alert_tests { caller_jid: "999000@s.whatsapp.net".into(), is_video: true, is_offline: false, - received_at: wacore::time::now_utc(), + received_at: oxidezap_core::time::now_utc(), } } diff --git a/crates/gui/src/app/events.rs b/crates/gui/src/app/events.rs index 4f2fcf062..cbfd2cead 100644 --- a/crates/gui/src/app/events.rs +++ b/crates/gui/src/app/events.rs @@ -207,7 +207,7 @@ impl WhatsAppApp { data: code, png_bytes: Arc::new(png_bytes), }) - .map(|qr| Issued::new(qr, timeout_secs, wacore::time::now_utc())) + .map(|qr| Issued::new(qr, timeout_secs, oxidezap_core::time::now_utc())) .or(previous); self.app_state = AppState::WaitingForPairing { qr_code: cached_qr, @@ -225,7 +225,11 @@ impl WhatsAppApp { }; self.app_state = AppState::WaitingForPairing { qr_code, - pair_code: Some(Issued::new(code, timeout_secs, wacore::time::now_utc())), + pair_code: Some(Issued::new( + code, + timeout_secs, + oxidezap_core::time::now_utc(), + )), }; self.ensure_heartbeat(cx); cx.notify(); diff --git a/crates/gui/src/app/notices.rs b/crates/gui/src/app/notices.rs index b1430c4d9..d507f1de9 100644 --- a/crates/gui/src/app/notices.rs +++ b/crates/gui/src/app/notices.rs @@ -119,7 +119,7 @@ impl Notices { self.push( text.into(), tone, - wacore::time::now_utc() + oxidezap_core::time::now_utc() + chrono::Duration::from_std(LIFETIME).unwrap_or(chrono::Duration::seconds(6)), ); self.sweep(cx); @@ -181,7 +181,7 @@ impl Notices { loop { crate::platform::sleep(SWEEP).await; let more = entity.update(cx, |notices, cx| { - if notices.expire(wacore::time::now_utc()) { + if notices.expire(oxidezap_core::time::now_utc()) { cx.notify(); } !notices.shown.is_empty() diff --git a/crates/gui/src/app/recovery.rs b/crates/gui/src/app/recovery.rs index 3a048d406..40dfa6ba7 100644 --- a/crates/gui/src/app/recovery.rs +++ b/crates/gui/src/app/recovery.rs @@ -51,7 +51,7 @@ impl Recovering { /// Seconds until the automatic retry, or `None` when none is scheduled. pub(super) fn countdown_secs(&self) -> Option { self.retry_at.map(|at| { - let now = wacore::time::now_utc(); + let now = oxidezap_core::time::now_utc(); (at - now).num_seconds().max(0) as u64 }) } @@ -99,8 +99,9 @@ impl Recovering { if self.retry_at.is_some() { return; } - self.retry_at = - Some(wacore::time::now_utc() + chrono::Duration::seconds(RETRY_AFTER_SECS as i64)); + self.retry_at = Some( + oxidezap_core::time::now_utc() + chrono::Duration::seconds(RETRY_AFTER_SECS as i64), + ); self.countdown = Some(cx.spawn(async move |me: WeakEntity, cx| { loop { @@ -450,7 +451,7 @@ mod tests { caller_jid: "999000@s.whatsapp.net".into(), is_video: false, is_offline: false, - received_at: wacore::time::now_utc(), + received_at: oxidezap_core::time::now_utc(), }); app.adopt_calls(ringing.clone(), cx); assert!(app.calls.read(cx).state().incoming().is_some()); @@ -483,7 +484,7 @@ mod tests { "nothing armed, nothing to count" ); - recovering.retry_at = Some(wacore::time::now_utc() + chrono::Duration::seconds(9)); + recovering.retry_at = Some(oxidezap_core::time::now_utc() + chrono::Duration::seconds(9)); assert!(matches!(recovering.countdown_secs(), Some(8 | 9))); } @@ -493,7 +494,7 @@ mod tests { #[test] fn a_deadline_already_past_reads_as_due() { let mut recovering = Recovering::new(); - recovering.retry_at = Some(wacore::time::now_utc() - chrono::Duration::seconds(30)); + recovering.retry_at = Some(oxidezap_core::time::now_utc() - chrono::Duration::seconds(30)); assert_eq!(recovering.countdown_secs(), Some(0)); } @@ -504,7 +505,7 @@ mod tests { #[test] fn working_offline_stops_the_wait() { let mut recovering = Recovering::new(); - recovering.retry_at = Some(wacore::time::now_utc() + chrono::Duration::seconds(15)); + recovering.retry_at = Some(oxidezap_core::time::now_utc() + chrono::Duration::seconds(15)); recovering.stop(); diff --git a/crates/gui/src/app/status.rs b/crates/gui/src/app/status.rs index cb329c054..b64de95bb 100644 --- a/crates/gui/src/app/status.rs +++ b/crates/gui/src/app/status.rs @@ -279,7 +279,7 @@ impl WhatsAppApp { let chat = self.chats.iter().find(|chat| chat.is_status); let count = chat.map_or(0, |chat| chat.messages.len()); - let now = wacore::time::now_utc(); + let now = oxidezap_core::time::now_utc(); let mut cache = self.status_feed_cache.borrow_mut(); // Count alone cannot see an update lapsing: nothing was added or // removed, the clock simply passed it. @@ -321,7 +321,7 @@ impl WhatsAppApp { // Saturating, and never zero: a lapse already past still needs one // turn of the loop to be noticed, and a negative duration would make // the timer fire in a tight loop. - let wait = (when - wacore::time::now_utc()) + let wait = (when - oxidezap_core::time::now_utc()) .to_std() .unwrap_or(std::time::Duration::ZERO) .max(std::time::Duration::from_secs(1)); diff --git a/crates/gui/src/components/chat_item.rs b/crates/gui/src/components/chat_item.rs index 07f22a2c9..b700b581c 100644 --- a/crates/gui/src/components/chat_item.rs +++ b/crates/gui/src/components/chat_item.rs @@ -176,7 +176,7 @@ fn render_name_row( ) .children( row.muted_until - .filter(|until| *until > wacore::time::now_utc()) + .filter(|until| *until > oxidezap_core::time::now_utc()) .map(|_| { div() .flex_shrink_0() diff --git a/crates/gui/src/components/status/list.rs b/crates/gui/src/components/status/list.rs index f2a1a329d..b0f7eb387 100644 --- a/crates/gui/src/components/status/list.rs +++ b/crates/gui/src/components/status/list.rs @@ -866,7 +866,7 @@ mod visible_cost { crate::theme::init(cx); }); let mut chat = oxidezap_core::Chat::new("status@broadcast".into()); - let now = wacore::time::now_utc(); + let now = oxidezap_core::time::now_utc(); for n in 0..50 { let mut message = oxidezap_core::ChatMessage::new_incoming( format!("S-{n}"), diff --git a/crates/gui/src/platform/notifications/call_alert.rs b/crates/gui/src/platform/notifications/call_alert.rs index b37e3c4e9..e7b980596 100644 --- a/crates/gui/src/platform/notifications/call_alert.rs +++ b/crates/gui/src/platform/notifications/call_alert.rs @@ -137,7 +137,9 @@ mod imp { let path = std::env::temp_dir().join(format!( "oxidezap-call-alert-failure-{}-{}", std::process::id(), - wacore::time::now_utc().timestamp_nanos_opt().unwrap() + oxidezap_core::time::now_utc() + .timestamp_nanos_opt() + .unwrap() )); let cancelled = Arc::new(AtomicBool::new(false)); let ringtone_cancelled = Arc::new(AtomicBool::new(false)); @@ -171,7 +173,9 @@ mod imp { let path = std::env::temp_dir().join(format!( "oxidezap-call-alert-test-{}-{}", std::process::id(), - wacore::time::now_utc().timestamp_nanos_opt().unwrap() + oxidezap_core::time::now_utc() + .timestamp_nanos_opt() + .unwrap() )); let owner = claim_at(&path, "call-one".into()).unwrap().unwrap(); assert!(claim_at(&path, "call-one".into()).unwrap().is_none()); diff --git a/crates/gui/src/utils.rs b/crates/gui/src/utils.rs index 9c05c89e8..d79e7ee71 100644 --- a/crates/gui/src/utils.rs +++ b/crates/gui/src/utils.rs @@ -97,7 +97,9 @@ pub fn scale_media_dimensions(width: u32, height: u32, max_size: f32) -> (f32, f /// out a full date on every row would make the column unscannable. pub fn format_list_time(timestamp: &DateTime) -> String { let local: DateTime = timestamp.with_timezone(&Local); - let today = wacore::time::now_utc().with_timezone(&Local).date_naive(); + let today = oxidezap_core::time::now_utc() + .with_timezone(&Local) + .date_naive(); let date = local.date_naive(); match (today - date).num_days() { @@ -118,7 +120,9 @@ pub fn format_list_time(timestamp: &DateTime) -> String { /// is what the hour tells you. pub fn format_status_time(timestamp: &DateTime) -> String { let local: DateTime = timestamp.with_timezone(&Local); - let today = wacore::time::now_utc().with_timezone(&Local).date_naive(); + let today = oxidezap_core::time::now_utc() + .with_timezone(&Local) + .date_naive(); match (today - local.date_naive()).num_days() { 0 => local.format(crate::tr!(TodayAtHM)).to_string(), @@ -130,7 +134,9 @@ pub fn format_status_time(timestamp: &DateTime) -> String { /// The heading over a group of messages sent on the same day. pub fn format_date_divider(timestamp: &DateTime) -> String { let local: DateTime = timestamp.with_timezone(&Local); - let today = wacore::time::now_utc().with_timezone(&Local).date_naive(); + let today = oxidezap_core::time::now_utc() + .with_timezone(&Local) + .date_naive(); match (today - local.date_naive()).num_days() { 0 => crate::tr!(Today).to_string(), diff --git a/crates/gui/src/views/pairing.rs b/crates/gui/src/views/pairing.rs index 5c332d2ca..2c9387475 100644 --- a/crates/gui/src/views/pairing.rs +++ b/crates/gui/src/views/pairing.rs @@ -229,7 +229,7 @@ fn render_expiry( cx: &App, ) -> impl IntoElement + use<> { let (left, remaining) = life - .map(|life| life.left_at(wacore::time::now_utc())) + .map(|life| life.left_at(oxidezap_core::time::now_utc())) .unwrap_or((0, 0.0)); let subtle = parts::subtle(cx); // Running out is worth noticing before it happens. diff --git a/crates/plugin-host/src/tests.rs b/crates/plugin-host/src/tests.rs index f31d729fd..7847e095c 100644 --- a/crates/plugin-host/src/tests.rs +++ b/crates/plugin-host/src/tests.rs @@ -1188,7 +1188,7 @@ fn the_schedule_plugin_submits_chat_forms_and_cancels_pending_messages() { std::thread::sleep(Duration::from_millis(1100)); assert!(plugins.approve("schedule", true)); - let due = wacore::time::now_utc() + Duration::from_secs(3); + let due = oxidezap_core::time::now_utc() + Duration::from_secs(3); plugins.act(&PluginAction { plugin: "schedule".into(), action: "schedule".into(), diff --git a/crates/session/src/store/registry.rs b/crates/session/src/store/registry.rs index 4c16c8d2e..2a8fb49d0 100644 --- a/crates/session/src/store/registry.rs +++ b/crates/session/src/store/registry.rs @@ -507,7 +507,7 @@ mod tests { &peer, "RETAINED", &whatsapp_rust::waproto::whatsapp::Message::default(), - wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) .unwrap(); history.flush().await.unwrap(); @@ -536,7 +536,7 @@ mod tests { &peer, "NEW-ACCOUNT", &whatsapp_rust::waproto::whatsapp::Message::default(), - wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) .unwrap(); new_history.flush().await.unwrap(); @@ -595,7 +595,7 @@ mod tests { &peer, "A-MSG", &whatsapp_rust::waproto::whatsapp::Message::default(), - wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) .expect("record A's message"); chat_b @@ -603,7 +603,7 @@ mod tests { &peer, "B-MSG", &whatsapp_rust::waproto::whatsapp::Message::default(), - wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) .expect("record B's message"); chat_a.flush().await.expect("flush A"); @@ -663,7 +663,7 @@ mod tests { &peer, "B-KEEP", &whatsapp_rust::waproto::whatsapp::Message::default(), - wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) .expect("record B's message"); chat_b.flush().await.expect("flush B"); diff --git a/crates/session/src/whatsapp/calls/registry.rs b/crates/session/src/whatsapp/calls/registry.rs index a659267b7..b4acf201e 100644 --- a/crates/session/src/whatsapp/calls/registry.rs +++ b/crates/session/src/whatsapp/calls/registry.rs @@ -42,7 +42,7 @@ const MAX_RINGABLE_OFFER_AGE_MS: i64 = 120_000; fn ringable_offer(offer: &WaIncomingCall, now_ms: i64) -> bool { !offer.offline && offer.timestamp.is_some_and(|timestamp| { - now_ms.saturating_sub(timestamp.timestamp_millis()) <= MAX_RINGABLE_OFFER_AGE_MS + now_ms.saturating_sub(timestamp.as_millis()) <= MAX_RINGABLE_OFFER_AGE_MS }) } @@ -3063,8 +3063,7 @@ mod tests { &ui, ); let mut old = (*replay_offer("BACKLOG")).clone(); - old.timestamp = - wacore::time::from_millis(old.timestamp.unwrap().timestamp_millis() - 300_000); + old.timestamp = wacore::time::from_millis(old.timestamp.unwrap().as_millis() - 300_000); assert!( !old.offline, "an offline flag is not required for freshness" @@ -3097,8 +3096,7 @@ mod tests { Arc::new(ui_queue::HistoryBudget::new()), ); let mut old = (*replay_offer("LOOKUP")).clone(); - old.timestamp = - wacore::time::from_millis(old.timestamp.unwrap().timestamp_millis() - 300_000); + old.timestamp = wacore::time::from_millis(old.timestamp.unwrap().as_millis() - 300_000); let old = Arc::new(old); // The registered offer is the one held across the name lookup; age // can change without either its identity or its epoch changing. diff --git a/crates/session/src/whatsapp/convert.rs b/crates/session/src/whatsapp/convert.rs index c73c2bb5b..1bf42d315 100644 --- a/crates/session/src/whatsapp/convert.rs +++ b/crates/session/src/whatsapp/convert.rs @@ -341,7 +341,7 @@ mod tests { id: "3EB0C".to_string(), sender_jid: "559900000001@s.whatsapp.net".parse().unwrap(), from_me: false, - timestamp: wacore::time::now_utc(), + timestamp: oxidezap_core::time::now_utc(), kind: oxidezap_chat_store::MessageKind::Poll, text: None, message: Some(Box::new(proto)), diff --git a/crates/session/src/whatsapp/mod.rs b/crates/session/src/whatsapp/mod.rs index 6a5dfa7d9..bac608736 100644 --- a/crates/session/src/whatsapp/mod.rs +++ b/crates/session/src/whatsapp/mod.rs @@ -1996,9 +1996,12 @@ impl WhatsAppClient { let cached_read = offline_reads .get(&inbound.info.source.chat.to_non_ad_string()) .map(|state| { - state - .as_ref() - .map(|state| state.covers(&inbound.info.id, inbound.info.timestamp)) + state.as_ref().map(|state| { + state.covers( + &inbound.info.id, + oxidezap_core::time::from_sdk(inbound.info.timestamp), + ) + }) }); Self::handle_inbound_message_with_read( &inbound.message, @@ -2133,9 +2136,11 @@ impl WhatsAppClient { Event::Presence(update) => { let availability = match update.status { PresenceStatus::Available => Availability::Online, - PresenceStatus::Unavailable => update - .last_seen - .map_or(Availability::Unknown, Availability::LastSeen), + PresenceStatus::Unavailable => { + update.last_seen.map_or(Availability::Unknown, |ts| { + Availability::LastSeen(oxidezap_core::time::from_sdk(ts)) + }) + } _ => Availability::Unknown, }; // Keyed like the receipt and chat-presence branches beside @@ -2168,10 +2173,10 @@ impl WhatsAppClient { chat_jid: update.group_jid.to_string(), notice_id: format!( "group-anonymous-{}-{}", - update.timestamp.timestamp_millis(), + update.timestamp.as_millis(), update.action_index ), - at: update.timestamp, + at: oxidezap_core::time::from_sdk(update.timestamp), notice: SystemNotice::GroupMembership(Box::new(event)), }); } @@ -2243,10 +2248,10 @@ impl WhatsAppClient { update .notification_id .clone() - .unwrap_or_else(|| update.timestamp.timestamp_millis().to_string()), + .unwrap_or_else(|| update.timestamp.as_millis().to_string()), update.action_index ), - at: update.timestamp, + at: oxidezap_core::time::from_sdk(update.timestamp), notice: SystemNotice::GroupChanged(text), }); } @@ -2403,7 +2408,7 @@ impl WhatsAppClient { sender_name: None, // Will be set in handle_message_received for groups content, is_text: oxidezap_chat_store::message_kind(base_msg) == "text", - timestamp: info.timestamp, + timestamp: oxidezap_core::time::from_sdk(info.timestamp), is_from_me: info.source.is_from_me, is_read: false, media: None, @@ -2578,7 +2583,11 @@ impl WhatsAppClient { } else { if let Some(store) = names.chat_store() { match store - .message_is_read(&info.source.chat, &info.id, info.timestamp) + .message_is_read( + &info.source.chat, + &info.id, + oxidezap_core::time::from_sdk(info.timestamp), + ) .await { Ok(read) => Some(read), @@ -3380,12 +3389,7 @@ fn record_outgoing( resolve_chat_names: &chat_names::ChatNameResolveSignal, ) -> Result<(), String> { store - .record_outgoing( - jid, - message_id, - message, - whatsapp_rust::wacore::time::now_utc(), - ) + .record_outgoing(jid, message_id, message, oxidezap_core::time::now_utc()) .map_err(|error| { // ChatStoreError's outer Display only says "storage error". Preserve // the admission reason so the caller can distinguish a full queue diff --git a/crates/session/src/whatsapp/mutations.rs b/crates/session/src/whatsapp/mutations.rs index 63bdc5a79..cc7ea021e 100644 --- a/crates/session/src/whatsapp/mutations.rs +++ b/crates/session/src/whatsapp/mutations.rs @@ -223,7 +223,12 @@ impl WhatsAppClient { let timestamp = wacore::time::from_millis(timestamp_ms) .ok_or_else(|| "edit was sent with an invalid timestamp".to_string())?; live.chat_store - .record_edit(&chat, &message_id, sent_content, timestamp) + .record_edit( + &chat, + &message_id, + sent_content, + oxidezap_core::time::from_sdk(timestamp), + ) .map_err(|e| format!("edit was sent but could not be saved locally: {e}"))?; live.chat_store .flush() @@ -309,7 +314,7 @@ impl WhatsAppClient { }, || { live.chat_store - .record_revoke(&chat, &message_id, wacore::time::now_utc()) + .record_revoke(&chat, &message_id, oxidezap_core::time::now_utc()) }, live.chat_store.flush(), ) @@ -346,7 +351,7 @@ impl WhatsAppClient { from_me, participant.clone(), timestamp, - wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) }, live.chat_store.flush(), diff --git a/crates/session/src/whatsapp/ops.rs b/crates/session/src/whatsapp/ops.rs index d55cc6175..1ac946979 100644 --- a/crates/session/src/whatsapp/ops.rs +++ b/crates/session/src/whatsapp/ops.rs @@ -572,7 +572,7 @@ impl WhatsAppClient { // The post is already on WhatsApp. A local write failure must // never prompt the user to send it a second time. - let now = whatsapp_rust::wacore::time::now_utc(); + let now = oxidezap_core::time::now_utc(); if let Err(error) = live.chat_store .record_outgoing(&jid, result.message_id.as_str(), &message, now) @@ -663,7 +663,7 @@ impl WhatsAppClient { // Already on WhatsApp: a failed local write must not invite a // second post. let jid = Jid::status_broadcast(); - let now = whatsapp_rust::wacore::time::now_utc(); + let now = oxidezap_core::time::now_utc(); if let Err(error) = live.chat_store .record_outgoing(&jid, result.message_id.as_str(), &message, now) diff --git a/crates/session/src/whatsapp/sends.rs b/crates/session/src/whatsapp/sends.rs index f627d8d41..c1f81c391 100644 --- a/crates/session/src/whatsapp/sends.rs +++ b/crates/session/src/whatsapp/sends.rs @@ -503,7 +503,7 @@ mod announcement_tests { &chat, format!("FILL-{index}"), &message, - whatsapp_rust::wacore::time::now_utc(), + oxidezap_core::time::now_utc(), ) .unwrap(); } diff --git a/crates/session/src/whatsapp/sticker_sync.rs b/crates/session/src/whatsapp/sticker_sync.rs index fafb7ee92..d98ec79dd 100644 --- a/crates/session/src/whatsapp/sticker_sync.rs +++ b/crates/session/src/whatsapp/sticker_sync.rs @@ -42,7 +42,7 @@ impl EventHandler for StickerSync { let Event::FavoriteStickerUpdate(update) = &*event else { return; }; - let timestamp = update.timestamp.timestamp_millis(); + let timestamp = update.timestamp.as_millis(); let mut entries = self .entries .lock() diff --git a/crates/session/src/whatsapp/tests.rs b/crates/session/src/whatsapp/tests.rs index e5fdcd43f..42c2bfae8 100644 --- a/crates/session/src/whatsapp/tests.rs +++ b/crates/session/src/whatsapp/tests.rs @@ -180,7 +180,7 @@ async fn a_sent_delete_succeeds_when_the_local_writer_has_stopped() { let result = super::mutations::delete_and_record( async { Ok::<_, String>(()) }, - || chat_store.record_revoke(&chat, "SENT-DELETE", wacore::time::now_utc()), + || chat_store.record_revoke(&chat, "SENT-DELETE", oxidezap_core::time::now_utc()), async { panic!("an unqueued delete must not await a flush") }, ) .await; @@ -2115,7 +2115,7 @@ fn alias_history_unread_deduplicates_only_matching_messages() { sender: "12025550143@s.whatsapp.net".to_string(), sender_name: None, content: id.to_string(), - timestamp: whatsapp_rust::wacore::time::now_utc(), + timestamp: oxidezap_core::time::now_utc(), is_from_me: false, is_read: false, media: None, @@ -2160,7 +2160,7 @@ fn watched_updates_come_back_watched() { sender: "12025550143@s.whatsapp.net".to_string(), sender_name: None, content: id.to_string(), - timestamp: whatsapp_rust::wacore::time::now_utc(), + timestamp: oxidezap_core::time::now_utc(), is_from_me: from_me, is_read: false, media: None, @@ -2724,7 +2724,9 @@ fn a_message_cursor_survives_the_round_trip() { id: "3EB0".to_string(), sender_jid: "5599000000001@s.whatsapp.net".parse().unwrap(), from_me: false, - timestamp: whatsapp_rust::wacore::time::from_millis(1_700_000_000_123).unwrap(), + timestamp: oxidezap_core::time::from_sdk( + wacore::Timestamp::from_millis(1_700_000_000_123).unwrap(), + ), kind: oxidezap_chat_store::MessageKind::Text, text: Some("olá".to_string()), message: None, @@ -2761,7 +2763,8 @@ fn stored_edit_state_reaches_own_and_peer_bubbles_in_direct_and_group_chats() { const PEER: &str = "559900000001@s.whatsapp.net"; const GROUP: &str = "120363000000000001@g.us"; - let timestamp = whatsapp_rust::wacore::time::from_millis(1_700_000_000_000).unwrap(); + let timestamp = + oxidezap_core::time::from_sdk(wacore::Timestamp::from_millis(1_700_000_000_000).unwrap()); for chat_jid in [PEER, GROUP] { for from_me in [false, true] { let stored = oxidezap_chat_store::StoredMessage { @@ -2852,11 +2855,15 @@ fn a_chat_cursor_keeps_an_address_with_a_colon_in_it() { let entry = ChatEntry { jid: "5599000000001:57@s.whatsapp.net".parse().unwrap(), name: None, - last_message_at: Some(whatsapp_rust::wacore::time::from_millis(1_700_000_000_123).unwrap()), + last_message_at: Some(oxidezap_core::time::from_sdk( + wacore::Timestamp::from_millis(1_700_000_000_123).unwrap(), + )), last_message_preview: None, last_message_kind: None, unread_count: 0, - pinned_at: Some(whatsapp_rust::wacore::time::from_millis(1_699_999_999_000).unwrap()), + pinned_at: Some(oxidezap_core::time::from_sdk( + wacore::Timestamp::from_millis(1_699_999_999_000).unwrap(), + )), muted_until: None, archived: false, ephemeral_expiration: None, diff --git a/crates/session/src/whatsapp/ui_queue.rs b/crates/session/src/whatsapp/ui_queue.rs index 154bbf409..0c7122598 100644 --- a/crates/session/src/whatsapp/ui_queue.rs +++ b/crates/session/src/whatsapp/ui_queue.rs @@ -869,7 +869,7 @@ mod tests { UiEvent::SystemNotice { chat_jid: "test@g.us".into(), notice_id: "id".into(), - at: wacore::time::from_secs(0).unwrap(), + at: oxidezap_core::time::from_sdk(wacore::Timestamp::UNIX_EPOCH), notice: oxidezap_core::SystemNotice::GroupChanged("x".repeat(4096)), }, ];