rhythia-api 182.0.0 → 184.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/createBeatmap.ts +12 -0
- package/api/deleteBeatmapPage.ts +7 -2
- package/api/nominateMap.ts +17 -4
- package/handleApi.ts +2 -0
- package/package.json +1 -1
- package/utils/star-calc/sspmParser.ts +2 -2
package/api/createBeatmap.ts
CHANGED
|
@@ -65,6 +65,18 @@ export async function handler({
|
|
|
65
65
|
return NextResponse.json({ error: "Bad user" });
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
if (
|
|
69
|
+
!parsedData.strings.mappers
|
|
70
|
+
.map((mapper) => mapper.toLowerCase().trim())
|
|
71
|
+
.includes((userData.username?.trim() || "").toLowerCase())
|
|
72
|
+
) {
|
|
73
|
+
return NextResponse.json({
|
|
74
|
+
error: `You are not among the authors of the map. If you made the map, please add yourself as an author in the editor. Mappers: ${JSON.stringify(
|
|
75
|
+
parsedData.strings.mappers
|
|
76
|
+
)}, Your name: ${userData.username}`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
68
80
|
if (
|
|
69
81
|
userData.ban == "excluded" ||
|
|
70
82
|
userData.ban == "restricted" ||
|
package/api/deleteBeatmapPage.ts
CHANGED
|
@@ -54,8 +54,13 @@ export async function handler({
|
|
|
54
54
|
if (!userData) return NextResponse.json({ error: "No user." });
|
|
55
55
|
if (!beatmapData) return NextResponse.json({ error: "No beatmap." });
|
|
56
56
|
|
|
57
|
-
if (userData.id !== pageData.owner)
|
|
58
|
-
|
|
57
|
+
if (userData.id !== pageData.owner) {
|
|
58
|
+
const isDev =
|
|
59
|
+
(userData.badges as string[]).includes("Developer") ||
|
|
60
|
+
(userData.badges as string[]).includes("Global Moderator");
|
|
61
|
+
|
|
62
|
+
if (!isDev) return NextResponse.json({ error: "Non-authz user." });
|
|
63
|
+
}
|
|
59
64
|
|
|
60
65
|
if (pageData.status !== "UNRANKED")
|
|
61
66
|
return NextResponse.json({ error: "Only unranked maps can be updated" });
|
package/api/nominateMap.ts
CHANGED
|
@@ -60,10 +60,23 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
|
|
|
60
60
|
return NextResponse.json({ error: "Already nominated" });
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
const newNominations = [
|
|
64
|
+
...(mapData.nominations! as number[]),
|
|
65
|
+
queryUserData.id,
|
|
66
|
+
];
|
|
67
|
+
if (newNominations.length == 2) {
|
|
68
|
+
await supabase.from("beatmapPages").upsert({
|
|
69
|
+
id: data.mapId,
|
|
70
|
+
nominations: newNominations,
|
|
71
|
+
status: "RANKED",
|
|
72
|
+
ranked_at: Date.now(),
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
await supabase.from("beatmapPages").upsert({
|
|
76
|
+
id: data.mapId,
|
|
77
|
+
nominations: newNominations,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
67
80
|
|
|
68
81
|
return NextResponse.json({});
|
|
69
82
|
}
|
package/handleApi.ts
CHANGED
|
@@ -9,6 +9,8 @@ export function setEnvironment(
|
|
|
9
9
|
export function handleApi<
|
|
10
10
|
T extends { url: string; input: z.ZodObject<any>; output: z.ZodObject<any> }
|
|
11
11
|
>(apiSchema: T) {
|
|
12
|
+
profanity.whitelist.addWords(["willy"]);
|
|
13
|
+
|
|
12
14
|
return async (input: T["input"]["_type"]): Promise<T["output"]["_type"]> => {
|
|
13
15
|
const response = await fetch(`https://${env}.rhythia.com${apiSchema.url}`, {
|
|
14
16
|
method: "POST",
|
package/package.json
CHANGED
|
@@ -136,6 +136,7 @@ export class SSPMParser {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
private readStringList(count: number): string[] {
|
|
139
|
+
console.log("[DANGER] Reading String List");
|
|
139
140
|
const list: string[] = [];
|
|
140
141
|
for (let i = 0; i < count; i++) {
|
|
141
142
|
list.push(this.readString());
|
|
@@ -281,8 +282,7 @@ export class SSPMParser {
|
|
|
281
282
|
mapID: this.readString(),
|
|
282
283
|
mapName: this.readString(),
|
|
283
284
|
songName: this.readString(),
|
|
284
|
-
mappers:
|
|
285
|
-
// mappers: this.readStringList(this.readUInt16()),
|
|
285
|
+
mappers: this.readStringList(this.readUInt16()),
|
|
286
286
|
};
|
|
287
287
|
|
|
288
288
|
let customData: CustomData = { fields: [] };
|