Skip to content

Persist owner locations and enable opt-in geofence discovery - #193

Open
nirmalhk7 wants to merge 4 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-location-persistence
Open

nirmalhk7 wants to merge 4 commits into
NTARI-RAND:mainfrom
nirmalhk7:nirmal/agrinet-location-persistence

Conversation

@nirmalhk7

@nirmalhk7 nirmalhk7 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What the change is

Adds working location saves, owner reloads, and nearby-location discovery.

Why it is needed

Saving currently reports success without writing to DynamoDB, and discovery always returns an empty list. Members cannot reliably save or find locations.

How the change works

An account token lets members save and reload their own location. Every save requires an explicit sharing choice: privacy: true shares exact coordinates; false keeps them private. Discovery filters by distance in kilometres and optional location type, checks at most 100 records per page, and returns only location fields. Encrypted continuation tokens support later pages without exposing private account IDs.

Locations stay in a separate local table so existing user and federation exports cannot expose this new data. Legacy coordinates are not automatically published. Existing account-security gaps remain separate work.

Where it is involved

Agrinet's /api/location routes, location controller, new backend/models/location.js, integration workflow, and API/deployment guide. Operators must provision the Locations table with string key id and backend read/write/scan permissions. This PR has no UI changes.

Verified locally: 37 Node tests, 46 Jest tests, and real DynamoDB persistence/privacy/pagination checks passed. Hosted workflows await maintainer approval.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
@nirmalhk7
nirmalhk7 marked this pull request as ready for review October 26, 2026 21:57
Comment thread backend/routes/locationRoutes.js Outdated

// Update coordinates for a user
router.post('/:id', locationController.setLocation);
router.post('/:id', locationController.requireOwner, locationController.setLocation);
Comment thread backend/routes/locationRoutes.js Outdated
// Update coordinates for a user
router.post('/:id', locationController.setLocation);
router.post('/:id', locationController.requireOwner, locationController.setLocation);
router.get('/:id', locationController.requireOwner, locationController.getLocation);
Comment thread backend/scripts/check-locations.js Outdated
const express = require('express');
const auth = require('../middleware/authMiddleware');
const app = express();
app.use(express.json(), auth);
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Limit owner reads and writes to 1,000 requests per minute. Keep a
guard before verification and an account budget after it so adding
an API key cannot bypass an exhausted account limit.

Bound the local storage-check server too. Preserve location privacy,
discovery and pagination, and retain current main's retry-safe messages.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Move input checks and saved-receipt replay into focused helpers. Extract
verification database setup and worker cleanup without changing request
results, receipt keys or lifecycle ordering.

Add a regression for a missing stored assistant reply: replay must return
410 without repeating delivery or returning a partial success.

Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants