![coyotte508's picture](https://cdn-avatars.huggingface.co/v1/production/uploads/61d2f90c3c2083e1c08af22d/jn21aKijwBnopk7aUJUkq.png)
coyotte508
HF staff
🐛 Some users have a time too different, let's set the date ourselves (#163)
da7f5d6
unverified
import { collections } from "$lib/server/database.js"; | |
import { z } from "zod"; | |
export async function PATCH({ locals, request }) { | |
const json = await request.json(); | |
const { ethicsModalAccepted, ...settings } = z | |
.object({ | |
shareConversationsWithModelAuthors: z.boolean().default(true), | |
ethicsModalAccepted: z.boolean().optional(), | |
}) | |
.parse(json); | |
await collections.settings.updateOne( | |
{ | |
sessionId: locals.sessionId, | |
}, | |
{ | |
$set: { | |
...settings, | |
...(ethicsModalAccepted && { ethicsModalAcceptedAt: new Date() }), | |
updatedAt: new Date(), | |
}, | |
$setOnInsert: { | |
createdAt: new Date(), | |
}, | |
}, | |
{ | |
upsert: true, | |
} | |
); | |
return new Response(); | |
} | |