Repository navigation
iPhone: security notices from FTW Cloud, and the car class in CloudView #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1138,7 +1138,7 @@ extension SiteModel { | |
| cloud = c | ||
| cloudHome = home | ||
| cloudStatus = c.status | ||
| if cloudOn { installPushSink() } | ||
| if takesAlerts { installPushSink() } | ||
| c.start() | ||
| } | ||
|
|
||
|
|
@@ -1194,11 +1194,18 @@ extension SiteModel { | |
| cloudDirty = true | ||
| persistNow() | ||
| startCloud() | ||
| // Alerts come with the readable copy, and only then is the person | ||
| // asked to allow them. | ||
| if cloudOn, cloud != nil { installPushSink() } else if !cloudOn { uninstallPushSink() } | ||
| // Alerts come with the readable copy, or to an owner's phone for the | ||
| // security notices whenever the box is linked, and only then is the | ||
| // person asked to allow them. | ||
| if takesAlerts, cloud != nil { installPushSink() } else if !takesAlerts { uninstallPushSink() } | ||
| } | ||
|
|
||
| /// Whether this phone registers for FTW Cloud's alerts: an owner's | ||
| /// whenever the box is linked, since security notices go to every owner | ||
| /// with the readable copy on or off; another phone only while the copy | ||
| /// carries its events. | ||
| private var takesAlerts: Bool { cloudOn || canConfigure } | ||
|
|
||
| // MARK: Pushes | ||
|
|
||
| /// The App Group files the notification extension reads. None in the | ||
|
|
@@ -1288,7 +1295,7 @@ extension SiteModel { | |
| guard var view = cloudView, (try? view.accept(env, arrivalMs: Int64(at))) != nil else { return false } | ||
| cloudView = view | ||
| switch env.t { | ||
| case CloudWire.msgLP: takeCloudCars(at) | ||
| case CloudWire.msgLP, CloudWire.msgCar: takeCloudCars(at) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a Useful? React with 👍 / 👎. |
||
| case CloudWire.msgPrices: takeCloudPrices(at) | ||
| default: break | ||
| } | ||
|
|
@@ -1397,13 +1404,16 @@ extension SiteModel { | |
| guard let view = cloudView, let lp = view.lp, let identity = cloudIdentity else { return } | ||
| let now = scheduler.nowMs | ||
| let g = view.grade(nowMs: Int64(now)) | ||
| let cars = lp.loadpoints.map { l in | ||
| let cars = lp.loadpoints.map(view.joined).map { l in | ||
| CarEntry.Car( | ||
| loadpointID: identity.loadpoints[l.id] ?? l.id, | ||
| pluggedIn: l.plugged, | ||
| socPct: l.socPermille.map { (Double($0) / 10).rounded() }, | ||
| socSource: l.socSource, | ||
| socReadAtMs: l.socAgeS.map { now - Double($0) * 1000 }, | ||
| // Dated from the message that carried the age: the car | ||
| // class's own send for a car. Without an anchor, a charger | ||
| // without a car is dated from now, as before cars. | ||
| socReadAtMs: view.socReadAtMs(l).map(Double.init) ?? (l.carId.isEmpty ? l.socAgeS.map { now - Double($0) * 1000 } : nil), | ||
| powerW: Double(l.powerW), | ||
| targetSocPct: l.targetPermille.map { (Double($0) / 10).rounded() } | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the box answers
hello,SessionState.roledefaults to owner, sotakesAlertsis true andstartCloudinstalls the push sink even for a viewer, removed phone, or other unconfirmed connection.PushTokens.installimmediately requests notification authorization; a later hello can uninstall the sink but cannot retract that one-time system prompt, and the asynchronous install can race with the uninstall. RequireheardFromBoxfor the owner-only branch while retainingcloudOnfor a known readable copy.Useful? React with 👍 / 👎.