2.1 KiB
2.1 KiB
1. Schema & Queries
- 1.1 Add idempotent
ALTER TABLE tags ADD COLUMN IF NOT EXISTS sms_enabled BOOLEAN NOT NULL DEFAULT TRUE;todb/schema.sql; runmake db-up(migrates existing DB) - 1.2 Add sqlc queries in
internal/db/queries.sql:InsertScan(tag_id, lat/lng nullable, location_shared, scanner_phone nullable),GetLastAlertByTag(latest scan with alert_sent=true),UpdateTagDetailsextended withsms_enabled;make generate - 1.3 New
internal/smspackage:Senderinterface,sms.NormalizeAU,sms.HaversineMeters;smslogsender;smsglobalHTTP client (REST, key+secret, JSON; field names confirmed with MXT docs)
2. Scan Handlers
- 2.1
internal/handlers/scan.go:POST /t/{tag_code}/scan— parse optional lat/lng, record scan, apply 250 m / 10-min throttle, send SMS per rules, setalert_sent - 2.2
POST /t/{tag_code}/contact— validate finder number, store on latest scan, SMS the owner with the finder's number - 2.3 Wire
internal/smssender intoApp(log sender whenSMS_API_KEYunset) + register routes inmain.go
3. Public Page JS & Templates
- 3.1
tag-public.html: geolocation script (prompt on load, POST scan with coords, re-check button shown until shared, hidden after),sms:link with prefilled body, finder contact form + inline error - 3.2 Branding sweep: "WhereWoof" → "Where Woof" in all templates + README;
<title>→ "Where Woof !"
4. Tag Management
- 4.1
tag-edit.html+tags.goedit handler:sms_enabledcheckbox (default checked), saved viaUpdateTagDetails
5. Verification
- 5.1 Extend the HTTP suite (
/tmp/verify.sh): scan with location → scan row + alert logged +alert_sent=true; same-location re-scan in window → no second alert; >250 m re-scan in window → second alert; after 10 min → alert;sms_enabled=false→ no alert; finder contact → stored + owner alert;sms:link and re-check button present; branding strings present - 5.2 Unit test haversine (known distances) + NormalizeAU cases
- 5.3 Manual real-SMS check to
+61423274487(real credentials, then removed) - 5.4
openspec validate scan-flow; commit