Add appeal submit status endpoint
This commit is contained in:
parent
b6c051f3cb
commit
ffe70100ac
@ -1,7 +1,28 @@
|
||||
import { jsonError } from "../../common.js";
|
||||
import { jsonError, jsonResponse } from "../../common.js";
|
||||
|
||||
export async function onRequestGet(context: RequestContext) {
|
||||
const { current_user: currentUser } = context.data;
|
||||
|
||||
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.env.DATA.get(`blockedappeal_${currentUser.id}`))
|
||||
)
|
||||
return jsonResponse('{"can_appeal":false}');
|
||||
|
||||
return jsonResponse('{"can_appeal":true}');
|
||||
}
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { learned, whyBanned, whyUnban } = context.data.body;
|
||||
if (await context.env.DATA.get("appeal_disabled"))
|
||||
return jsonError("Appeals are disabled", 403);
|
||||
|
||||
const { learned, senderTokenId, whyBanned, whyUnban } = context.data.body;
|
||||
|
||||
if (
|
||||
typeof learned !== "string" ||
|
||||
@ -58,6 +79,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
JSON.stringify({
|
||||
ban_reason: whyBanned,
|
||||
created_at: Date.now(),
|
||||
fcm_token: typeof senderTokenId === "string" ? senderTokenId : undefined,
|
||||
learned,
|
||||
id: appealId,
|
||||
reason_for_unban: whyUnban,
|
||||
|
Loading…
x
Reference in New Issue
Block a user