rhythia-api 168.0.0 → 169.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.
@@ -10,6 +10,7 @@ export const Schema = {
10
10
  session: z.string(),
11
11
  data: z.object({
12
12
  avatar_url: z.string().optional(),
13
+ profile_image: z.string().optional(),
13
14
  username: z.string().optional(),
14
15
  }),
15
16
  }),
@@ -89,6 +89,18 @@ export async function handler({
89
89
 
90
90
  const user = (await getUserBySession(session)) as User;
91
91
 
92
+ let { data: leversData } = await supabase
93
+ .from("levers")
94
+ .select("*")
95
+ .eq("id", 1)
96
+ .single();
97
+
98
+ if (leversData && leversData.disable_scores) {
99
+ return NextResponse.json({
100
+ error: "Scores are temporarily disabled",
101
+ });
102
+ }
103
+
92
104
  let { data: userData, error: userError } = await supabase
93
105
  .from("profiles")
94
106
  .select("*")
@@ -174,7 +186,10 @@ export async function handler({
174
186
  multiplierMod *= Math.pow(0.95, data.misses);
175
187
  }
176
188
 
177
- if (beatmaps.starRating && beatmaps.starRating == data.virtualStars) {
189
+ if (
190
+ beatmaps.starRating &&
191
+ Math.abs(beatmaps.starRating - data.virtualStars) < 0.01
192
+ ) {
178
193
  awarded_sp = calculatePerformancePoints(
179
194
  data.speed * beatmaps.starRating * multiplierMod,
180
195
  accurracy
@@ -252,7 +267,7 @@ export async function handler({
252
267
  });
253
268
  console.log("p3");
254
269
 
255
- if (awarded_sp > 99) {
270
+ if (awarded_sp > 99 && userData.ban == "cool") {
256
271
  await postToWebhooks({
257
272
  rp: Math.round(awarded_sp * 100) / 100,
258
273
  username: userData.username || "",
@@ -268,6 +283,12 @@ export async function handler({
268
283
  });
269
284
  }
270
285
 
286
+ if (Math.abs((beatmaps.starRating || 0) - data.virtualStars) > 0.01) {
287
+ return NextResponse.json({
288
+ error: "Map mismatch, no RP points were awarded, please report the bug.",
289
+ });
290
+ }
291
+
271
292
  return NextResponse.json({});
272
293
  }
273
294
 
package/index.ts CHANGED
@@ -92,6 +92,7 @@ export const Schema = {
92
92
  session: z.string(),
93
93
  data: z.object({
94
94
  avatar_url: z.string().optional(),
95
+ profile_image: z.string().optional(),
95
96
  username: z.string().optional(),
96
97
  }),
97
98
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "168.0.0",
3
+ "version": "169.0.0",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "update": "bun ./scripts/update.ts",
package/types/database.ts CHANGED
@@ -168,6 +168,21 @@ export type Database = {
168
168
  }
169
169
  Relationships: []
170
170
  }
171
+ levers: {
172
+ Row: {
173
+ disable_scores: boolean
174
+ id: number
175
+ }
176
+ Insert: {
177
+ disable_scores?: boolean
178
+ id?: number
179
+ }
180
+ Update: {
181
+ disable_scores?: boolean
182
+ id?: number
183
+ }
184
+ Relationships: []
185
+ }
171
186
  passkeys: {
172
187
  Row: {
173
188
  email: string
@@ -23,7 +23,15 @@ export async function protectedApi({
23
23
  const toParse = await request.json();
24
24
  const data = schema.input.parse(toParse);
25
25
 
26
- console.log({ ...data, session: undefined });
26
+ const dataClone = structuredClone(data);
27
+ if (dataClone) {
28
+ if (dataClone["token"]) {
29
+ dataClone["token"] = "********";
30
+ }
31
+ Object.keys(dataClone).forEach((key) => {
32
+ console.log("KEY: ", key, dataClone[key]);
33
+ });
34
+ }
27
35
 
28
36
  setActivity(data);
29
37
  if (authorization) {