From 25152ddb61a89ea3ea29d3aef5de13343429d32a Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Fri, 9 Oct 2026 18:23:52 +0200 Subject: feat: back up the phone's photos to a group, once a day on Wi-Fi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Android application sends the photos taken on the phone to one folder of one group chosen by the member (docs/MESHBAY_DESIGN.md §9.12). The phone lists MediaStore, keeps a ledger of what was sent and hands each photo's bytes to the page by an opaque token on the packaged origin; the page decides when a run is due and uploads through the existing path, one photo at a time under a slot. - Once a day from the last finished run, on an unmetered network only; "Back up now" asks first on mobile data. Leaving Wi-Fi stops after the file in flight. - Photos already on the phone are sent by default, newest first, under /YYYY/MM; edits are sent beside the original as -edited-. - Additive by construction: nothing is ever deleted, renamed or replaced on the node, and a photo deleted on the node is not sent again. - A confirmation names the group, owner, members, folder and size when the destination or starting point changes; a lasting refusal (disk full, folder read-only or gone, no longer a member) is said once and retried a day later. - No ACCESS_MEDIA_LOCATION, so the platform redacts photo locations. - A dataSync foreground service keeps a run going with the screen off. HEIC/HEIF photos are sent but not shown in Photos yet (§15.2). Co-Authored-By: Claude Opus 5.5 --- .../meshbay-hub/src/meshbay_hub/static/platform.js | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js index c70b03a..c5ae9ee 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js @@ -230,6 +230,31 @@ export const push = { }, }; +/** + * Backing up this phone's photos to a group (docs/MESHBAY_DESIGN.md §9.12). + * Only the Android application has a camera roll to read; `available` is false + * in a browser and on a desktop. See photo-sync.js. + */ +export const photoSync = { + available: Boolean(bridge && bridge.photoSync), + status() { return bridge.photoSync.status(); }, + permit() { return bridge.photoSync.permit(); }, + albums() { return bridge.photoSync.albums(); }, + configure(settings) { return bridge.photoSync.configure(settings); }, + estimate(settings) { return bridge.photoSync.estimate(settings); }, + plan() { return bridge.photoSync.plan(); }, + sent(token, dir, name) { return bridge.photoSync.sent(token, dir, name); }, + completed() { return bridge.photoSync.completed(); }, + failed(code, text) { return bridge.photoSync.failed(code, text); }, + keepAlive(on, text) { return bridge.photoSync.keepAlive(on, text); }, + /** The bytes of a photo the last plan issued, as a File named for the node. */ + async file(token, name) { + const r = await fetch(`/photosync/${encodeURIComponent(token)}`, { cache: 'no-store' }); + if (!r.ok) throw new Error('This photo is no longer on the phone'); + return new File([await r.blob()], name); + }, +}; + /** Pick a directory to add as a group root. Returns { path, name } or null. */ export const rootPicker = { available: Boolean(bridge && bridge.rootPicker), -- cgit v1.2.3