Add option for filing hiatuses

This commit is contained in:
2023-11-04 13:40:02 -04:00
parent daace88cf9
commit 4ddf797cc2
3 changed files with 30 additions and 1 deletions

View File

@ -1,11 +1,13 @@
import validateInactivity from "./validate.js";
export async function onRequestPost(context: RequestContext) {
const { departments, end, reason, senderTokenId, start } = context.data.body;
const { departments, end, hiatus, reason, senderTokenId, start } =
context.data.body;
const validationFailureResponse = validateInactivity(
departments,
end,
hiatus,
reason,
start,
context.data.departments,
@ -25,6 +27,7 @@ export async function onRequestPost(context: RequestContext) {
departments,
end,
fcm_token: typeof senderTokenId === "string" ? senderTokenId : undefined,
hiatus,
open: true,
reason,
start,

View File

@ -3,6 +3,7 @@ import { jsonError } from "../../common.js";
export default function (
selectedDepartments: string[],
end: any,
hiatus: any,
reason: any,
start: any,
userDepartments?: string[],
@ -28,6 +29,12 @@ export default function (
const now = new Date();
const startDate = new Date(start);
if (typeof hiatus !== "undefined" && typeof hiatus !== "boolean")
return jsonError("Invalid notice", 400);
if (!selectedDepartments.includes("DM") && hiatus)
return jsonError("Only discord mods can file hiatuses", 400);
if (
isNaN(endDate.getFullYear()) ||
isNaN(startDate.getFullYear()) ||