From ff2553eb0f56b48d2ca33e69d94fc9e2350438e1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 6 Oct 2024 16:07:32 -0500 Subject: [PATCH] Return a PushSubscription response --- src/controllers/api/push.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/controllers/api/push.ts b/src/controllers/api/push.ts index f442064e..2541966c 100644 --- a/src/controllers/api/push.ts +++ b/src/controllers/api/push.ts @@ -58,7 +58,7 @@ export const pushSubscribeController: AppController = async (c) => { const { subscription, data } = result.data; - await kysely + const { id } = await kysely .insertInto('push_subscriptions') .values({ pubkey: await signer.getPublicKey(), @@ -68,7 +68,14 @@ export const pushSubscribeController: AppController = async (c) => { auth: subscription.keys.auth, data, }) - .execute(); + .returning('id') + .executeTakeFirstOrThrow(); - return c.json({}); + return c.json({ + id, + endpoint: subscription.endpoint, + alerts: data?.alerts ?? {}, + policy: data?.policy ?? 'all', + // TODO: server_key + }); };