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