Migrate reports submission
All checks were successful
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 54s
Test, Build, Deploy / Create Sentry Release (push) Successful in 6s

This commit is contained in:
2026-04-11 03:50:41 -04:00
parent b5e230e7f2
commit 930128c0d4

View File

@@ -225,26 +225,31 @@ export async function onRequestPost(context: RequestContext) {
attachments.push(new URL(urlResult.value).pathname.replace(/^\/?t?\//, "")); attachments.push(new URL(urlResult.value).pathname.replace(/^\/?t?\//, ""));
} }
await context.env.D1.prepare( await context.data.prisma.report.create({
"INSERT INTO reports (attachments, created_at, id, open, target_ids, target_usernames, type, user) VALUES (?, ?, ?, 1, ?, ?, ?, ?);", data: {
) attachments,
.bind( id: reportId,
JSON.stringify(attachments), target_ids: metaIDs,
Date.now(), target_usernames: metaNames,
reportId, type: submissionType,
JSON.stringify(metaIDs), user: currentUser
JSON.stringify(metaNames), ? {
submissionType, email: currentUser.email,
currentUser ? JSON.stringify(currentUser) : null, id: currentUser.id,
) username: currentUser.username,
.run(); }
: undefined,
},
});
if (typeof senderTokenId === "string") if (typeof senderTokenId === "string")
await context.env.D1.prepare( await context.data.prisma.pushNotification.create({
"INSERT INTO push_notifications (created_at, event_id, event_type, token) VALUES (?, ?, ?, ?);", data: {
) event_id: reportId,
.bind(Date.now(), reportId, "report", senderTokenId) event_type: reportId,
.run(); token: senderTokenId,
},
});
return jsonResponse( return jsonResponse(
JSON.stringify({ id: reportId, upload_urls: uploadUrls }), JSON.stringify({ id: reportId, upload_urls: uploadUrls }),