From b282bf6470e43cc7f9e839b631c89214fa2fa6ac Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Wed, 10 Dec 2025 18:52:11 +0100 Subject: [PATCH] Fix D1 storage: Insert service_id when creating offers The createOffers function was not inserting the service_id column even though it was passed in the CreateOfferRequest. This caused all offers to have NULL service_id, making getOffersForService return empty results. Fixed: - Added service_id to INSERT statement in createOffers - Added serviceId to created offer objects - Added serviceId to rowToOffer mapping This resolves the 'No available offers' error when trying to connect to a published service. --- src/storage/d1.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/storage/d1.ts b/src/storage/d1.ts index 99f1f72..192f760 100644 --- a/src/storage/d1.ts +++ b/src/storage/d1.ts @@ -115,13 +115,14 @@ export class D1Storage implements Storage { const now = Date.now(); await this.db.prepare(` - INSERT INTO offers (id, peer_id, sdp, created_at, expires_at, last_seen, secret) - VALUES (?, ?, ?, ?, ?, ?, ?) - `).bind(id, offer.peerId, offer.sdp, now, offer.expiresAt, now, offer.secret || null).run(); + INSERT INTO offers (id, peer_id, service_id, sdp, created_at, expires_at, last_seen, secret) + VALUES (?, ?, ?, ?, ?, ?, ?, ?) + `).bind(id, offer.peerId, offer.serviceId || null, offer.sdp, now, offer.expiresAt, now, offer.secret || null).run(); created.push({ id, peerId: offer.peerId, + serviceId: offer.serviceId, sdp: offer.sdp, createdAt: now, expiresAt: offer.expiresAt, @@ -565,6 +566,7 @@ export class D1Storage implements Storage { return { id: row.id, peerId: row.peer_id, + serviceId: row.service_id || undefined, sdp: row.sdp, createdAt: row.created_at, expiresAt: row.expires_at,