rhythia-api 196.0.0 → 197.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.
@@ -45,7 +45,19 @@ export async function handler(data: (typeof Schema)["input"]["_type"]) {
45
45
  });
46
46
  }
47
47
 
48
- if (data.resourceId !== queryUserData.clan?.toString()) {
48
+ let { data: clanQuery, error: clanError } = await supabase
49
+ .from("clans")
50
+ .select("*")
51
+ .eq("id", queryUserData.clan || -1)
52
+ .single();
53
+
54
+ if (!clanQuery) {
55
+ return NextResponse.json({
56
+ error: "You're not in a clan",
57
+ });
58
+ }
59
+
60
+ if (data.resourceId !== (clanQuery.owner || -1).toString()) {
49
61
  return NextResponse.json({
50
62
  error: "You can't create invite for a clan that you aren't owner of.",
51
63
  });
@@ -98,7 +98,7 @@ export async function handler(
98
98
  let { data: queryData, error } = await supabase
99
99
  .from("profiles")
100
100
  .select("*")
101
- .eq("computedUsername", data.data.support_note)
101
+ .eq("computedUsername", data.data.support_note.toLowerCase())
102
102
  .single();
103
103
 
104
104
  if (queryData) {
@@ -110,7 +110,7 @@ export async function handler(
110
110
  let { data: queryData, error } = await supabase
111
111
  .from("profiles")
112
112
  .select("*")
113
- .eq("computedUsername", data.data.supporter_name)
113
+ .eq("computedUsername", data.data.supporter_name.toLowerCase())
114
114
  .single();
115
115
 
116
116
  if (queryData) {
@@ -0,0 +1,41 @@
1
+ import { NextResponse } from "next/server";
2
+ import z from "zod";
3
+ import { protectedApi, validUser } from "../utils/requestUtils";
4
+ import { supabase } from "../utils/supabase";
5
+ import { User } from "@supabase/supabase-js";
6
+ import { getUserBySession } from "../utils/getUserBySession";
7
+
8
+ export const Schema = {
9
+ input: z.strictObject({
10
+ session: z.string(),
11
+ }),
12
+ output: z.strictObject({}),
13
+ };
14
+
15
+ export async function POST(request: Request): Promise<NextResponse> {
16
+ return protectedApi({
17
+ request,
18
+ schema: Schema,
19
+ authorization: () => {},
20
+ activity: handler,
21
+ });
22
+ }
23
+
24
+ export async function handler(
25
+ data: (typeof Schema)["input"]["_type"]
26
+ ): Promise<NextResponse<(typeof Schema)["output"]["_type"]>> {
27
+ const user = (await getUserBySession(data.session)) as User;
28
+ let { data: queryData, error } = await supabase
29
+ .from("profiles")
30
+ .select("*")
31
+ .eq("uid", user.id)
32
+ .single();
33
+
34
+ if (!queryData) {
35
+ NextResponse.json({});
36
+ }
37
+
38
+ console.log("CHEATER: " + queryData);
39
+
40
+ return NextResponse.json({});
41
+ }
@@ -112,7 +112,7 @@ export async function handler({
112
112
  {
113
113
  error: "User doesn't exist",
114
114
  },
115
- { status: 500 }
115
+ { status: 400 }
116
116
  );
117
117
 
118
118
  console.log(userData);
@@ -143,7 +143,7 @@ export async function handler({
143
143
  {
144
144
  error: "Map not submitted",
145
145
  },
146
- { status: 500 }
146
+ { status: 400 }
147
147
  );
148
148
  }
149
149
 
@@ -152,7 +152,7 @@ export async function handler({
152
152
  {
153
153
  error: "Map not submitted",
154
154
  },
155
- { status: 500 }
155
+ { status: 400 }
156
156
  );
157
157
  }
158
158
 
@@ -162,7 +162,7 @@ export async function handler({
162
162
  {
163
163
  error: "Wrong map",
164
164
  },
165
- { status: 500 }
165
+ { status: 400 }
166
166
  );
167
167
  }
168
168
 
package/index.ts CHANGED
@@ -1054,6 +1054,19 @@ import { Schema as GetUserScores } from "./api/getUserScores"
1054
1054
  export { Schema as SchemaGetUserScores } from "./api/getUserScores"
1055
1055
  export const getUserScores = handleApi({url:"/api/getUserScores",...GetUserScores})
1056
1056
 
1057
+ // ./api/getVerified.ts API
1058
+
1059
+ /*
1060
+ export const Schema = {
1061
+ input: z.strictObject({
1062
+ session: z.string(),
1063
+ }),
1064
+ output: z.strictObject({}),
1065
+ };*/
1066
+ import { Schema as GetVerified } from "./api/getVerified"
1067
+ export { Schema as SchemaGetVerified } from "./api/getVerified"
1068
+ export const getVerified = handleApi({url:"/api/getVerified",...GetVerified})
1069
+
1057
1070
  // ./api/nominateMap.ts API
1058
1071
 
1059
1072
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rhythia-api",
3
- "version": "196.0.0",
3
+ "version": "197.0.0",
4
4
  "main": "index.ts",
5
5
  "author": "online-contributors-cunev",
6
6
  "scripts": {