Migrate reports submission
This commit is contained in:
@@ -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 }),
|
||||||
|
|||||||
Reference in New Issue
Block a user