rhythia-api 198.0.0 → 199.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/executeAdminOperation.ts +13 -6
- package/package.json +1 -1
- package/types/database.ts +22 -6
|
@@ -12,6 +12,7 @@ const adminOperations = {
|
|
|
12
12
|
excludeUser: z.object({ userId: z.number() }),
|
|
13
13
|
restrictUser: z.object({ userId: z.number() }),
|
|
14
14
|
silenceUser: z.object({ userId: z.number() }),
|
|
15
|
+
profanityClear: z.object({ userId: z.number() }),
|
|
15
16
|
searchUsers: z.object({ searchText: z.string() }),
|
|
16
17
|
removeAllScores: z.object({ userId: z.number() }),
|
|
17
18
|
invalidateRankedScores: z.object({ userId: z.number() }),
|
|
@@ -40,6 +41,10 @@ const OperationParam = z.discriminatedUnion("operation", [
|
|
|
40
41
|
operation: z.literal("searchUsers"),
|
|
41
42
|
params: adminOperations.searchUsers,
|
|
42
43
|
}),
|
|
44
|
+
z.object({
|
|
45
|
+
operation: z.literal("profanityClear"),
|
|
46
|
+
params: adminOperations.profanityClear,
|
|
47
|
+
}),
|
|
43
48
|
z.object({
|
|
44
49
|
operation: z.literal("removeAllScores"),
|
|
45
50
|
params: adminOperations.removeAllScores,
|
|
@@ -97,13 +102,9 @@ export async function handler(
|
|
|
97
102
|
{ status: 404 }
|
|
98
103
|
);
|
|
99
104
|
}
|
|
100
|
-
|
|
105
|
+
const tags = (queryUserData?.badges || []) as string[];
|
|
101
106
|
// Check if user has "Global Moderator" badge
|
|
102
|
-
const
|
|
103
|
-
const isGlobalModerator =
|
|
104
|
-
badges &&
|
|
105
|
-
Array.isArray(badges.badges) &&
|
|
106
|
-
badges.badges.some((badge: any) => badge === "Global Moderator");
|
|
107
|
+
const isGlobalModerator = tags.includes("Global Moderator");
|
|
107
108
|
|
|
108
109
|
if (!isGlobalModerator) {
|
|
109
110
|
return NextResponse.json(
|
|
@@ -152,6 +153,12 @@ export async function handler(
|
|
|
152
153
|
});
|
|
153
154
|
break;
|
|
154
155
|
|
|
156
|
+
case "profanityClear":
|
|
157
|
+
result = await supabase.rpc("admin_profanity_clear", {
|
|
158
|
+
user_id: params.userId,
|
|
159
|
+
});
|
|
160
|
+
break;
|
|
161
|
+
|
|
155
162
|
case "removeAllScores":
|
|
156
163
|
result = await supabase.rpc("admin_remove_all_scores", {
|
|
157
164
|
user_id: params.userId,
|
package/package.json
CHANGED
package/types/database.ts
CHANGED
|
@@ -615,14 +615,30 @@ export type Database = {
|
|
|
615
615
|
}
|
|
616
616
|
Returns: number
|
|
617
617
|
}
|
|
618
|
-
admin_log_action:
|
|
618
|
+
admin_log_action:
|
|
619
|
+
| {
|
|
620
|
+
Args: {
|
|
621
|
+
admin_id: number
|
|
622
|
+
action_type: string
|
|
623
|
+
target_id: number
|
|
624
|
+
details?: Json
|
|
625
|
+
}
|
|
626
|
+
Returns: undefined
|
|
627
|
+
}
|
|
628
|
+
| {
|
|
629
|
+
Args: {
|
|
630
|
+
admin_id: number
|
|
631
|
+
action_type: string
|
|
632
|
+
target_id: string
|
|
633
|
+
details?: Json
|
|
634
|
+
}
|
|
635
|
+
Returns: undefined
|
|
636
|
+
}
|
|
637
|
+
admin_profanity_clear: {
|
|
619
638
|
Args: {
|
|
620
|
-
|
|
621
|
-
action_type: string
|
|
622
|
-
target_id: string
|
|
623
|
-
details?: Json
|
|
639
|
+
user_id: number
|
|
624
640
|
}
|
|
625
|
-
Returns:
|
|
641
|
+
Returns: boolean
|
|
626
642
|
}
|
|
627
643
|
admin_remove_all_scores: {
|
|
628
644
|
Args: {
|