Permalink
Newer
100644
48 lines (41 sloc)
1.4 KB
7
reason: any,
8
start: any,
9
userDepartments?: string[],
10
): void | Response {
11
if (!userDepartments) return jsonError("Not part of any departments", 403);
12
13
if (
14
!Array.isArray(selectedDepartments) ||
15
!selectedDepartments.length ||
16
typeof end !== "string" ||
17
typeof reason !== "string" ||
18
typeof start !== "string"
19
)
21
22
if (!selectedDepartments.every((dept) => userDepartments.includes(dept)))
24
"Cannot file an inactivity notice in a department you are not part of",
25
403,
26
);
27
28
const endDate = new Date(end);
29
const now = new Date();
30
const startDate = new Date(start);
31
32
if (typeof hiatus !== "undefined" && typeof hiatus !== "boolean")
33
return jsonError("Invalid notice", 400);
34
35
if (!selectedDepartments.includes("DM") && hiatus)
36
return jsonError("Only discord mods can file hiatuses", 400);
37
38
if (
39
isNaN(endDate.getFullYear()) ||
40
isNaN(startDate.getFullYear()) ||
41
endDate.getFullYear() < now.getFullYear() ||
42
endDate.getFullYear() > now.getFullYear() + 1 ||
43
startDate.getFullYear() < now.getFullYear() ||
44
startDate.getFullYear() > now.getFullYear() + 1 ||
45
endDate.valueOf() < startDate.valueOf()
46
)