mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-11 19:33:25 +00:00
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.
This commit is contained in:
@@ -115,13 +115,14 @@ export class D1Storage implements Storage {
|
|||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
await this.db.prepare(`
|
await this.db.prepare(`
|
||||||
INSERT INTO offers (id, peer_id, sdp, created_at, expires_at, last_seen, secret)
|
INSERT INTO offers (id, peer_id, service_id, sdp, created_at, expires_at, last_seen, secret)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`).bind(id, offer.peerId, offer.sdp, now, offer.expiresAt, now, offer.secret || null).run();
|
`).bind(id, offer.peerId, offer.serviceId || null, offer.sdp, now, offer.expiresAt, now, offer.secret || null).run();
|
||||||
|
|
||||||
created.push({
|
created.push({
|
||||||
id,
|
id,
|
||||||
peerId: offer.peerId,
|
peerId: offer.peerId,
|
||||||
|
serviceId: offer.serviceId,
|
||||||
sdp: offer.sdp,
|
sdp: offer.sdp,
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
expiresAt: offer.expiresAt,
|
expiresAt: offer.expiresAt,
|
||||||
@@ -565,6 +566,7 @@ export class D1Storage implements Storage {
|
|||||||
return {
|
return {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
peerId: row.peer_id,
|
peerId: row.peer_id,
|
||||||
|
serviceId: row.service_id || undefined,
|
||||||
sdp: row.sdp,
|
sdp: row.sdp,
|
||||||
createdAt: row.created_at,
|
createdAt: row.created_at,
|
||||||
expiresAt: row.expires_at,
|
expiresAt: row.expires_at,
|
||||||
|
|||||||
Reference in New Issue
Block a user