// `people.fillCities` — Cotton filling in a person's city from their zone. // // | method | takes | answers | // |---|---|---| // | `people.fillCities` | nothing | `{filled: [{id, city, timezone}]}` | // | `people.unfillCities` | `{at}` | `{cleared: [id]}` | // // **A method, not a tool.** Nobody asks for it: the app runs it on each // foreground, and it fills the city of every person who has a time zone and // has never had a city (Europe/London → London). Every fill inside it is the // `update_person` tool an assistant would have called, through this device's // outbox, so it syncs. It never overwrites a city, never fills a person twice, // and never asks the network — `crates/cotton-ffi/src/phone/people_city.rs` // says how each of those holds. Each pass is stamped, Home's Done for you lists // it, and `people.unfillCities` takes one pass back from there. import Foundation extension CottonMethod { /// `people.fillCities` — fill in the city of every person owed one. public static let peopleFillCities = "people.fillCities" /// `people.unfillCities` — take one pass of the fill back. public static let peopleUnfillCities = "people.unfillCities" } /// `people.unfillCities`' request: the pass's instant, as Done for you named it. struct UnfillCitiesRequest: Encodable, Sendable { let at: String } extension CottonCalling { /// One pass of the fill. Answers what it filled — usually nothing. @discardableResult public func fillPersonCities() async throws -> JSONValue { try await callJSON(CottonMethod.peopleFillCities) } /// Clear the cities of the pass at `at` that still stand. Answers the /// people it cleared. @discardableResult public func unfillPersonCities(at: String) async throws -> JSONValue { try await callJSON(CottonMethod.peopleUnfillCities, UnfillCitiesRequest(at: at)) } }