KV to D1 migration (this is totally gonna break something)
This commit is contained in:
@ -20,11 +20,25 @@ export async function onRequestPost(context: RequestContext) {
|
||||
context.data.targetId = id;
|
||||
|
||||
if (!pathname.endsWith("/ban")) {
|
||||
const key = await context.env.DATA.get(`appeal_${id}`);
|
||||
const appeal: Record<string, any> | null = await context.env.D1.prepare(
|
||||
"SELECT * FROM appeals WHERE id = ?;",
|
||||
)
|
||||
.bind(id)
|
||||
.first();
|
||||
|
||||
if (!key) return jsonError("No appeal with that ID exists", 404);
|
||||
if (!appeal) return jsonError("No appeal with that ID exists", 404);
|
||||
|
||||
context.data.appeal = JSON.parse(key);
|
||||
appeal.user = JSON.parse(appeal.user);
|
||||
context.data.appeal = appeal;
|
||||
|
||||
const pushNotificationData = await context.env.D1.prepare(
|
||||
"SELECT token FROM push_notifications WHERE event_id = ? AND event_type = 'appeal';",
|
||||
)
|
||||
.bind(id)
|
||||
.first();
|
||||
|
||||
if (pushNotificationData)
|
||||
context.data.fcm_token = pushNotificationData.token;
|
||||
}
|
||||
|
||||
if (
|
||||
|
Reference in New Issue
Block a user