//! "Tell the owner about THIS one."//!//! SERVER-LOCAL, never synced — an underscore table. It exists because filing//! and reading came apart: an assistant files a document and the WORKER reads//! it, minutes later, in another call stack entirely, so the intent has to be//! written down somewhere between the two.//!//! It is emphatically NOT written on the document. `source` is the owner's own//! record of who filed a thing — "you" or "your assistant" — and bending it to//! `app` so a push would fire makes the file lie about its own history forever//! to buy one notification. The intent is the server's business; the provenance//! is the owner's.use cotton_store::driver::Driver;use rusqlite::types::ValueasSqlValue;const DDL: &str = "CREATE TABLE IF NOT EXISTS _document_notify_optin ( document_id TEXT PRIMARY KEY, created_at TEXT NOT NULL);";fn ensure(db: &Driver) -> Result<(), String> { db.exec(DDL).map_err(|error| error.to_string())}/// Remember that this filing asked to be announced.pubfn mark_notify_opt_in(db: &Driver, document_id: &str, now_iso: &str) -> Result<(), String> { ensure(db)?; db.run("INSERT INTO _document_notify_optin (document_id, created_at) VALUES (?, ?) ON CONFLICT (document_id) DO NOTHING", &[SqlValue::Text(document_id.to_string()),SqlValue::Text(now_iso.to_string()), ], ) .map_err(|error| error.to_string())?;Ok(())}