More stuff to migrate
This commit is contained in:
@@ -40,13 +40,15 @@ export async function loader({ context }: { context: RequestContext }) {
|
||||
status: 403,
|
||||
});
|
||||
|
||||
const { results } = await context.env.D1.prepare(
|
||||
"SELECT destination, path FROM short_links WHERE user = ?;",
|
||||
)
|
||||
.bind(userId)
|
||||
.all();
|
||||
|
||||
return results as Record<string, string>[];
|
||||
return await context.data.prisma.shortLink.findMany({
|
||||
select: {
|
||||
destination: true,
|
||||
path: true,
|
||||
},
|
||||
where: {
|
||||
user: userId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export default function () {
|
||||
|
||||
@@ -6,11 +6,12 @@ export async function onRequestGet(context: RequestContext) {
|
||||
if (
|
||||
!currentUser.email ||
|
||||
(await context.env.DATA.get("appeal_disabled")) ||
|
||||
(await context.env.D1.prepare(
|
||||
"SELECT id FROM appeals WHERE open = 1 AND user = ?;",
|
||||
)
|
||||
.bind(currentUser.id)
|
||||
.first()) ||
|
||||
(await context.data.prisma.appeal.findFirst({
|
||||
where: {
|
||||
approved: null,
|
||||
user: currentUser.id,
|
||||
},
|
||||
})) ||
|
||||
(await context.env.DATA.get(`blockedappeal_${currentUser.id}`))
|
||||
)
|
||||
return jsonResponse('{"can_appeal":false}');
|
||||
@@ -47,18 +48,24 @@ export async function onRequestPost(context: RequestContext) {
|
||||
|
||||
if (
|
||||
existingBlockedAppeal ||
|
||||
(await context.env.D1.prepare(
|
||||
"SELECT approved FROM appeals WHERE approved IS NULL AND json_extract(user, '$.id') = ?;",
|
||||
)
|
||||
.bind(currentUser.id)
|
||||
.first())
|
||||
(await context.data.prisma.appeal.findFirst({
|
||||
where: {
|
||||
approved: null,
|
||||
user: {
|
||||
path: "id",
|
||||
equals: currentUser.id,
|
||||
},
|
||||
},
|
||||
}))
|
||||
)
|
||||
return jsonError("Appeal already submitted", 403);
|
||||
|
||||
if (
|
||||
await context.env.D1.prepare("SELECT * FROM appeal_bans WHERE user = ?;")
|
||||
.bind(currentUser.id)
|
||||
.first()
|
||||
await context.data.prisma.appealBan.findUnique({
|
||||
where: {
|
||||
user: currentUser.id,
|
||||
},
|
||||
})
|
||||
) {
|
||||
await context.env.DATA.put(`blockedappeal_${currentUser.id}`, "1", {
|
||||
metadata: { email: currentUser.email },
|
||||
@@ -73,29 +80,28 @@ export async function onRequestPost(context: RequestContext) {
|
||||
.randomUUID()
|
||||
.replaceAll("-", "")}`;
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO appeals (ban_reason, created_at, id, learned, reason_for_unban, user) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
)
|
||||
.bind(
|
||||
whyBanned,
|
||||
Date.now(),
|
||||
appealId,
|
||||
await context.data.prisma.appeal.create({
|
||||
data: {
|
||||
ban_reason: whyBanned,
|
||||
id: appealId,
|
||||
learned,
|
||||
whyUnban,
|
||||
JSON.stringify({
|
||||
reason_for_unban: whyUnban,
|
||||
user: {
|
||||
email: currentUser.email,
|
||||
id: currentUser.id,
|
||||
username: currentUser.username,
|
||||
}),
|
||||
)
|
||||
.run();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (typeof senderTokenId === "string") {
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO push_notifications (created_at, event_id, event_type, token) VALUES (?, ?, 'appeal', ?)",
|
||||
)
|
||||
.bind(Date.now(), appealId, senderTokenId)
|
||||
.run();
|
||||
await context.data.prisma.pushNotification.create({
|
||||
data: {
|
||||
event_id: appealId,
|
||||
event_type: "appeal",
|
||||
token: senderTokenId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await fetch(context.env.APPEALS_WEBHOOK, {
|
||||
|
||||
@@ -52,19 +52,16 @@ export async function onRequestPost(context: RequestContext) {
|
||||
context.request.headers.get("cf-ray")?.split("-")[0]
|
||||
}${Date.now()}`;
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO game_appeals (created_at, id, reason_for_unban, roblox_id, roblox_username, type, what_happened) VALUES (?, ?, ?, ?, ?, ?, ?);",
|
||||
)
|
||||
.bind(
|
||||
Date.now(),
|
||||
appealId,
|
||||
reasonForUnban,
|
||||
id,
|
||||
username,
|
||||
await context.data.prisma.gameAppeal.create({
|
||||
data: {
|
||||
id: appealId,
|
||||
reason_for_unban: reasonForUnban,
|
||||
roblox_id: id,
|
||||
roblox_username: username,
|
||||
type,
|
||||
whatHappened,
|
||||
)
|
||||
.run();
|
||||
what_happened: whatHappened,
|
||||
},
|
||||
});
|
||||
|
||||
await fetch(context.env.REPORTS_WEBHOOK, {
|
||||
body: JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user