KV to D1 migration (this is totally gonna break something)
This commit is contained in:
@ -20,34 +20,33 @@ export async function onRequestPost(context: RequestContext) {
|
||||
(context.request.headers.get("cf-ray") as string).split("-")[0] +
|
||||
Date.now().toString();
|
||||
|
||||
await context.env.DATA.put(
|
||||
`inactivity_${inactivityId}`,
|
||||
JSON.stringify({
|
||||
created_at: Date.now(),
|
||||
departments,
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO inactivity_notices (created_at, departments, end, hiatus, id, reason, start, user) VALUES (?, ?, ?, ?, ?, ?, ?, ?);",
|
||||
)
|
||||
.bind(
|
||||
Date.now(),
|
||||
JSON.stringify(departments),
|
||||
end,
|
||||
fcm_token: typeof senderTokenId === "string" ? senderTokenId : undefined,
|
||||
hiatus,
|
||||
open: true,
|
||||
Number(hiatus),
|
||||
inactivityId,
|
||||
reason,
|
||||
start,
|
||||
user: {
|
||||
JSON.stringify({
|
||||
id: context.data.current_user.id,
|
||||
email: context.data.current_user.email,
|
||||
username: context.data.current_user.username,
|
||||
},
|
||||
}),
|
||||
{
|
||||
expirationTtl: 63072000,
|
||||
},
|
||||
);
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO inactivity_notices (created_at, id, user) VALUES (?, ?, ?);",
|
||||
)
|
||||
.bind(Date.now(), inactivityId, context.data.current_user.id)
|
||||
}),
|
||||
)
|
||||
.run();
|
||||
|
||||
if (typeof senderTokenId === "string") {
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO push_notifications (created_at, event_id, event_type) VALUES (?, ?, ?);",
|
||||
)
|
||||
.bind(Date.now(), inactivityId, "inactivity")
|
||||
.run();
|
||||
}
|
||||
|
||||
const departmentsToNotify = [];
|
||||
const departmentRoles = [];
|
||||
const { env } = context;
|
||||
|
Reference in New Issue
Block a user