rhythia-api 129.0.0 → 130.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/approveMap.ts CHANGED
@@ -60,6 +60,12 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
60
60
  });
61
61
  }
62
62
 
63
+ if ((mapData.nominations as number[]).includes(queryUserData.id)) {
64
+ return NextResponse.json({
65
+ error: "Can't nominate and approve",
66
+ });
67
+ }
68
+
63
69
  await supabase.from("beatmapPages").upsert({
64
70
  id: data.mapId,
65
71
  status: "RANKED",
@@ -50,6 +50,17 @@ export async function handler({
50
50
  let sum = require("crypto").createHash("sha1");
51
51
  sum.update(Buffer.from(bytes));
52
52
  const digested = sum.digest("hex");
53
+
54
+ let { data: beatmapPage, error: errorlast } = await supabase
55
+ .from("beatmapPages")
56
+ .select(`*`)
57
+ .eq("latestBeatmapHash", digested)
58
+ .single();
59
+
60
+ if (beatmapPage) {
61
+ return NextResponse.json({ error: "Already Exists" });
62
+ }
63
+
53
64
  const imgkey = `beatmap-img-${Date.now()}-${digested}`;
54
65
 
55
66
  let buffer = Buffer.from([]);
@@ -36,7 +36,7 @@ export async function handler(
36
36
  );
37
37
  }
38
38
 
39
- if (data.data.about_me.length > 500) {
39
+ if (data.data.about_me.length > 10000) {
40
40
  return NextResponse.json(
41
41
  {
42
42
  error: "Too long.",
@@ -15,9 +15,6 @@ export const Schema = {
15
15
  flag: z.string().nullable(),
16
16
  id: z.number(),
17
17
  username: z.string().nullable(),
18
- play_count: z.number().nullable(),
19
- skill_points: z.number().nullable(),
20
- total_score: z.number().nullable(),
21
18
  })
22
19
  )
23
20
  .optional(),
@@ -43,7 +40,7 @@ export async function handler(
43
40
  export async function getLeaderboard(badge: string) {
44
41
  let { data: queryData, error } = await supabase
45
42
  .from("profiles")
46
- .select("*")
43
+ .select("flag,id,username,badges")
47
44
  .neq("ban", "excluded");
48
45
 
49
46
  const users = queryData?.filter((e) =>
@@ -54,9 +51,6 @@ export async function getLeaderboard(badge: string) {
54
51
  leaderboard: users?.map((user) => ({
55
52
  flag: user.flag,
56
53
  id: user.id,
57
- play_count: user.play_count,
58
- skill_points: user.skill_points,
59
- total_score: user.total_score,
60
54
  username: user.username,
61
55
  })),
62
56
  };
package/handleApi.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  let env = "development";
3
+ import { profanity, CensorType } from "@2toad/profanity";
3
4
  export function setEnvironment(
4
5
  stage: "development" | "testing" | "production"
5
6
  ) {
@@ -13,7 +14,7 @@ export function handleApi<
13
14
  method: "POST",
14
15
  body: JSON.stringify(input),
15
16
  });
16
- const output = await response.json();
17
- return output;
17
+ const output = await response.text();
18
+ return JSON.parse(profanity.censor(output));
18
19
  };
19
20
  }