Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Reminders: deleting a list deletes the reminders in it, found from Apple's records (live ones left behind showed in the phone's Calendar from a list nobody could see); cleaned 13 such test leftovers
Yashwanth Kamireddiddb25c2e1527
diff --git a/crates/quince-icloud/src/reminders.rs b/crates/quince-icloud/src/reminders.rsindex c06707e..c60a640 100644--- a/crates/quince-icloud/src/reminders.rs+++ b/crates/quince-icloud/src/reminders.rs@@ -1753,6 +1753,28 @@ pub async fn delete_list_cloudkit(list_guid: &str,) -> Result<()> {let client = ZoneClient::new(http, ckdatabasews_root, CONTAINER, params);+ // The reminders in it go with it. Marking only the list left them alive in a list nobody+ // can see: Reminders hid them, but Calendar on the phone still showed every one with a+ // date — a "Daily test" ringing from a list deleted days before. Found from Apple's own+ // records, so the completed copies Apple's server made of a repeating one go too.+ let walk = client.all_records(ZONE, None).await?;+ for r in walk.records.iter().filter(|r| in_list(r, list_guid)) {+ let Some(guid) = r.get("recordName").and_then(Value::as_str) else {+ continue;+ };+ client+ .update_record_signed(+ ZONE,+ guid,+ "Reminder",+ None,+ serde_json::json!({+ "Deleted": { "type": "NUMBER_INT64", "value": 1 },+ "LastModifiedDate": { "type": "TIMESTAMP", "value": now_millis() },+ }),+ )+ .await?;+ }client.update_record_signed(ZONE,@@ -1767,6 +1789,15 @@ pub async fn delete_list_cloudkit(Ok(())}+/// Whether a record is a live reminder in this list.+fn in_list(r: &Value, list_guid: &str) -> bool {+ r.get("recordType").and_then(Value::as_str) == Some("Reminder")+ && r.pointer("/fields/Deleted/value").and_then(Value::as_i64) != Some(1)+ && r.pointer("/fields/List/value/recordName")+ .and_then(Value::as_str)+ == Some(list_guid)+}+/// Tick a CloudKit reminder off, or put it back.////// Sends only the fields that change, guarded by the record's change tag, so a reminder@@ -2658,16 +2689,55 @@ mod list_write_tests {assert!(op["record"]["fields"].get("Deleted").is_none());}- /// Deleting marks the flag Apple's own clients use rather than destroying the record.+ /// Deleting marks the flag Apple's own clients use rather than destroying the record —+ /// and the list's live reminders go with it, so none is left in a list nobody can see,+ /// still showing in the phone's Calendar. Nothing in another list is touched.#[tokio::test]async fn deleting_marks_rather_than_destroys() {let server = accepting().await;+ let reminder = |name: &str, list: &str, deleted: i64| {+ json!({+ "recordName": name, "recordType": "Reminder", "recordChangeTag": "t",+ "fields": { "List": { "value": { "recordName": list } }, "Deleted": { "value": deleted } },+ })+ };+ Mock::given(method("POST"))+ .and(path_regex(r".*/changes/zone$"))+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({ "zones": [{+ "records": [reminder("Reminder/in", "List/a", 0), reminder("Reminder/other", "List/b", 0), reminder("Reminder/gone", "List/a", 1)],+ "syncToken": "s", "moreComing": false,+ }] })))+ .mount(&server)+ .await;delete_list_cloudkit(&reqwest::Client::new(), &server.uri(), vec![], "List/a").await.unwrap();- let op = sent(&server).await;- assert_eq!(op["operationType"], "update");- assert_eq!(op["record"]["fields"]["Deleted"]["value"], 1);+ let written: Vec<(String, Value)> = server+ .received_requests()+ .await+ .unwrap()+ .iter()+ .filter(|r| r.url.path().ends_with("/records/modify"))+ .map(|r| {+ let op = serde_json::from_slice::<Value>(&r.body).unwrap()["operations"][0].clone();+ (+ op["record"]["recordName"]+ .as_str()+ .unwrap_or("")+ .to_string(),+ op["record"]["fields"]["Deleted"]["value"].clone(),+ )+ })+ .collect();+ assert_eq!(+ written,+ [+ ("Reminder/in".to_string(), json!(1)),+ ("List/a".to_string(), json!(1))+ ],+ "the list's live reminder, then the list"+ );+ let _ = sent(&server).await;}#[tokio::test]diff --git a/probe/examples/find_test_leftovers.rs b/probe/examples/find_test_leftovers.rsnew file mode 100644index 0000000..1fe64fa--- /dev/null+++ b/probe/examples/find_test_leftovers.rs@@ -0,0 +1,99 @@+//! Read-only: every reminder and calendar event whose title mentions "test", with what keeps+//! it alive — deleted or not, its list and whether that list is deleted, due date, repeat.+use anyhow::{anyhow, Result};+use serde_json::Value;+#[tokio::main]+async fn main() -> Result<()> {+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");+ let mut client = quince_auth::Client::new(&dir)?;+ if !client.resume().await? {+ return Err(anyhow!("no session"));+ }+ let ck = client+ .session()+ .service_url("ckdatabasews")+ .ok_or_else(|| anyhow!("no ck"))?;+ let (http, p) = (client.http().clone(), client.service_params());+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &ck, "com.apple.reminders", p.clone());+ let walk = zc.all_records("Reminders", None).await?;+ let text = |v: &Value| {+ v.as_str()+ .and_then(quince_icloud::ckdocument::text_from_base64)+ .unwrap_or_default()+ };+ let lists: std::collections::HashMap<String, (String, i64)> = walk+ .records+ .iter()+ .filter(|r| r["recordType"] == "List")+ .map(|r| {+ let name = r["fields"]["Name"]["value"]+ .as_str()+ .map(|s| {+ String::from_utf8(+ base64::Engine::decode(&base64::engine::general_purpose::STANDARD, s)+ .unwrap_or_default(),+ )+ .unwrap_or_default()+ })+ .unwrap_or_default();+ (+ r["recordName"].as_str().unwrap_or("").to_string(),+ (name, r["fields"]["Deleted"]["value"].as_i64().unwrap_or(0)),+ )+ })+ .collect();+ for r in walk+ .records+ .iter()+ .filter(|r| r["recordType"] == "Reminder")+ {+ let f = &r["fields"];+ let title = text(&f["TitleDocument"]["value"]);+ if !title.to_lowercase().contains("test") {+ continue;+ }+ let list = f["List"]["value"]["recordName"].as_str().unwrap_or("");+ println!(+ "REMINDER {:?} id={} deleted={} completed={} due={} allday={} recur={} list={:?}",+ title,+ r["recordName"],+ f["Deleted"]["value"],+ f["Completed"]["value"],+ f["DueDate"]["value"],+ f["AllDay"]["value"],+ f["RecurrenceRuleIDs"]["value"]+ .to_string()+ .chars()+ .take(60)+ .collect::<String>(),+ lists.get(list)+ );+ }+ let cal_root = client+ .session()+ .service_url("calendar")+ .ok_or_else(|| anyhow!("no calendar"))?;+ let cal = quince_icloud::calendar::CalendarClient::new(&http, &cal_root, p.clone());+ for (a, b) in [+ ("2026-09-01", "2026-09-30"),+ ("2026-10-01", "2026-10-31"),+ ("2026-11-01", "2026-11-30"),+ ] {+ match cal.startup(a, b, "Asia/Kolkata").await {+ Ok(snap) => {+ for e in snap+ .events+ .iter()+ .filter(|e| e.title.to_lowercase().contains("test"))+ {+ println!(+ "EVENT {:?} guid={} cal={} starts={} allday={}",+ e.title, e.guid, e.calendar_guid, e.starts_at, e.all_day+ );+ }+ }+ Err(e) => println!("{a}: {e}"),+ }+ }+ Ok(())+}diff --git a/probe/examples/reminders_orphans.rs b/probe/examples/reminders_orphans.rsnew file mode 100644index 0000000..5017547--- /dev/null+++ b/probe/examples/reminders_orphans.rs@@ -0,0 +1,69 @@+//! Reminders left alive inside deleted lists — invisible in Reminders, still shown by the+//! phone's Calendar. Lists them; with `--delete`, marks deleted only those whose title this+//! probe's own tests use ("Daily test", "All-day test", "A", "B", "C"). Nothing else.+use anyhow::{anyhow, Result};+use serde_json::Value;+#[tokio::main]+async fn main() -> Result<()> {+ let delete = std::env::args().any(|a| a == "--delete");+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");+ let mut client = quince_auth::Client::new(&dir)?;+ if !client.resume().await? {+ return Err(anyhow!("no session"));+ }+ let ck = client+ .session()+ .service_url("ckdatabasews")+ .ok_or_else(|| anyhow!("no ck"))?;+ let (http, p) = (client.http().clone(), client.service_params());+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &ck, "com.apple.reminders", p.clone());+ let walk = zc.all_records("Reminders", None).await?;+ let dead: std::collections::HashSet<&str> = walk+ .records+ .iter()+ .filter(|r| {+ r["recordType"] == "List" && r["fields"]["Deleted"]["value"].as_i64() == Some(1)+ })+ .filter_map(|r| r["recordName"].as_str())+ .collect();+ let ours = ["Daily test", "All-day test", "A", "B", "C"];+ let mut n = 0;+ for r in walk.records.iter().filter(|r| {+ r["recordType"] == "Reminder" && r["fields"]["Deleted"]["value"].as_i64() != Some(1)+ }) {+ let list = r["fields"]["List"]["value"]["recordName"]+ .as_str()+ .unwrap_or("");+ if !dead.contains(list) {+ continue;+ }+ let title = r["fields"]["TitleDocument"]["value"]+ .as_str()+ .and_then(quince_icloud::ckdocument::text_from_base64)+ .unwrap_or_default();+ let name = r["recordName"].as_str().unwrap_or("");+ let mine = ours.contains(&title.as_str());+ println!(+ "{} {:?} in deleted list {list} — {}",+ name,+ title,+ if mine { "ours" } else { "NOT OURS, left alone" }+ );+ if delete && mine {+ zc.update_record_signed(+ "Reminders",+ name,+ "Reminder",+ None,+ serde_json::json!({+ "Deleted": { "type": "NUMBER_INT64", "value": 1 },+ }),+ )+ .await?;+ n += 1;+ }+ }+ let _: Option<Value> = None;+ println!("{n} marked deleted");+ Ok(())+}