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?\//, ""));
}
await context.env.D1.prepare(
"INSERT INTO reports (attachments, created_at, id, open, target_ids, target_usernames, type, user) VALUES (?, ?, ?, 1, ?, ?, ?, ?);",
)
.bind(
JSON.stringify(attachments),
Date.now(),
reportId,
JSON.stringify(metaIDs),
JSON.stringify(metaNames),
submissionType,
currentUser ? JSON.stringify(currentUser) : null,
)
.run();
await context.data.prisma.report.create({
data: {
attachments,
id: reportId,
target_ids: metaIDs,
target_usernames: metaNames,
type: submissionType,
user: currentUser
? {
email: currentUser.email,
id: currentUser.id,
username: currentUser.username,
}
: undefined,
},
});
if (typeof senderTokenId === "string")
await context.env.D1.prepare(
"INSERT INTO push_notifications (created_at, event_id, event_type, token) VALUES (?, ?, ?, ?);",
)
.bind(Date.now(), reportId, "report", senderTokenId)
.run();
await context.data.prisma.pushNotification.create({
data: {
event_id: reportId,
event_type: reportId,
token: senderTokenId,
},
});
return jsonResponse(
JSON.stringify({ id: reportId, upload_urls: uploadUrls }),