Skip to main content

sync_once/
sync_once.rs

1//! Inspect one initial sync page after QR login. No cursor or history is committed.
2mod support;
3
4fn main() -> anyhow::Result<()> {
5    if std::env::args().skip(1).any(|arg| arg == "--help") {
6        println!("sync_once: approve a test-account QR login and summarize one initial sync page.");
7        return Ok(());
8    }
9    let (client, mut state) = support::login()?;
10    let batch = client.sync(&mut state, &[])?;
11    let mut messages = 0;
12    for command in &batch.commands {
13        if command.id == 5 {
14            let _message =
15                wechat_protocol::wire::decode_add_message(&command.payload, &state.own_username)?;
16            messages += 1;
17        }
18    }
19    println!(
20        "commands={} add_messages={} other_commands={} continuation={}",
21        batch.commands.len(),
22        messages,
23        batch.commands.len() - messages,
24        batch.continuation
25    );
26    // This is a preview, not a sync consumer: all raw commands remain in `batch`,
27    // and we never save its returned cursor. A persistent client must retain and
28    // handle every required command before committing that cursor.
29    println!("Preview only. No history or sync cursor was saved.");
30    Ok(())
31}