Return a PushSubscription response

This commit is contained in:
Alex Gleason 2024-10-06 16:07:32 -05:00
parent 757b6c7e1c
commit ff2553eb0f
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -58,7 +58,7 @@ export const pushSubscribeController: AppController = async (c) => {
const { subscription, data } = result.data; const { subscription, data } = result.data;
await kysely const { id } = await kysely
.insertInto('push_subscriptions') .insertInto('push_subscriptions')
.values({ .values({
pubkey: await signer.getPublicKey(), pubkey: await signer.getPublicKey(),
@ -68,7 +68,14 @@ export const pushSubscribeController: AppController = async (c) => {
auth: subscription.keys.auth, auth: subscription.keys.auth,
data, 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
});
}; };