Compare commits
2 Commits
5457898ff9
...
da0ce2b188
| Author | SHA1 | Date | |
|---|---|---|---|
|
da0ce2b188
|
|||
|
6da49d191a
|
@@ -40,11 +40,17 @@ export async function loader({ context }: { context: RequestContext }) {
|
|||||||
!Boolean(disabled) &&
|
!Boolean(disabled) &&
|
||||||
!Boolean(await dataKV.get(`blockedappeal_${currentUser.id}`)) &&
|
!Boolean(await dataKV.get(`blockedappeal_${currentUser.id}`)) &&
|
||||||
!Boolean(
|
!Boolean(
|
||||||
await context.env.D1.prepare(
|
await context.data.prisma.appeal.findFirst({
|
||||||
"SELECT * FROM appeals WHERE approved IS NULL AND json_extract(user, '$.id') = ? LIMIT 1;",
|
select: {
|
||||||
)
|
id: true,
|
||||||
.bind(currentUser.id)
|
},
|
||||||
.first(),
|
where: {
|
||||||
|
user: {
|
||||||
|
path: "id",
|
||||||
|
equals: currentUser.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
can_toggle:
|
can_toggle:
|
||||||
currentUser.permissions & (1 << 0) || currentUser.permissions & (1 << 11),
|
currentUser.permissions & (1 << 0) || currentUser.permissions & (1 << 11),
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { jsonError, jsonResponse } from "../../common.js";
|
import { jsonResponse } from "../../common.js";
|
||||||
|
|
||||||
export async function onRequestGet(context: RequestContext) {
|
export async function onRequestGet(context: RequestContext) {
|
||||||
const { results, success } = await context.env.D1.prepare(
|
|
||||||
"SELECT approved, created_at, id, open FROM appeals WHERE user = ?;",
|
|
||||||
)
|
|
||||||
.bind(context.data.current_user.id)
|
|
||||||
.all();
|
|
||||||
|
|
||||||
if (!success) return jsonError("Unable to retrieve appeals", 500);
|
|
||||||
|
|
||||||
return jsonResponse(
|
return jsonResponse(
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
results.map((result) => {
|
await context.data.prisma.appeal.findMany({
|
||||||
result.user = JSON.parse(result.user as string);
|
select: {
|
||||||
|
approved: true,
|
||||||
return result;
|
created_at: true,
|
||||||
|
id: true,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
user: {
|
||||||
|
path: "id",
|
||||||
|
equals: context.data.current_user.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ export async function onRequestGet(context: RequestContext) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const urls = (await Promise.all(urlPromises)).map((p) => p.url);
|
const urls = (await Promise.all(urlPromises)).map((p) => p.url);
|
||||||
item = Object.defineProperty(item, "resolved_attachments", {
|
item = { ...item, resolved_attachments: urls };
|
||||||
value: urls,
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user