Don't add to kv for new events
This commit is contained in:
parent
bf6fdc7719
commit
4ba23c2ad5
@ -62,9 +62,10 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
const id = `${now.getTime()}${crypto.randomUUID().replaceAll("-", "")}`;
|
const id = `${now.getTime()}${crypto.randomUUID().replaceAll("-", "")}`;
|
||||||
|
|
||||||
await context.env.D1.prepare(
|
await context.env.D1.prepare(
|
||||||
"INSERT INTO events (created_at, created_by, day, id, month, type, year) VALUES (?, ?, ?, ?, ?, ?, ?);",
|
"INSERT INTO events (answer, created_at, created_by, day, id, month, type, year) VALUES (?, ?, ?, ?, ?, ?, ?);",
|
||||||
)
|
)
|
||||||
.bind(
|
.bind(
|
||||||
|
context.data.body.answer || null,
|
||||||
now.getTime(),
|
now.getTime(),
|
||||||
context.data.current_user.id,
|
context.data.current_user.id,
|
||||||
day,
|
day,
|
||||||
@ -75,23 +76,6 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
await context.env.DATA.put(
|
|
||||||
`event_${id}`,
|
|
||||||
JSON.stringify({
|
|
||||||
answer: context.data.body.answer,
|
|
||||||
created_at: now.getTime(),
|
|
||||||
created_by: context.data.current_user.id,
|
|
||||||
day,
|
|
||||||
details,
|
|
||||||
month: currentMonth,
|
|
||||||
pending: true,
|
|
||||||
year: currentYear,
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
expirationTtl: 15552000,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: 204,
|
status: 204,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user