rhythia-api 200.0.0 → 201.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 +15 -0
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import { User } from "@supabase/supabase-js";
|
|
|
9
9
|
// Define supported admin operations and their parameter types
|
|
10
10
|
const adminOperations = {
|
|
11
11
|
deleteUser: z.object({ userId: z.number() }),
|
|
12
|
+
changeFlag: z.object({ userId: z.number(), flag: z.string() }),
|
|
12
13
|
excludeUser: z.object({ userId: z.number() }),
|
|
13
14
|
restrictUser: z.object({ userId: z.number() }),
|
|
14
15
|
silenceUser: z.object({ userId: z.number() }),
|
|
@@ -57,6 +58,10 @@ const OperationParam = z.discriminatedUnion("operation", [
|
|
|
57
58
|
operation: z.literal("unbanUser"),
|
|
58
59
|
params: adminOperations.unbanUser,
|
|
59
60
|
}),
|
|
61
|
+
z.object({
|
|
62
|
+
operation: z.literal("changeFlag"),
|
|
63
|
+
params: adminOperations.changeFlag,
|
|
64
|
+
}),
|
|
60
65
|
]);
|
|
61
66
|
|
|
62
67
|
export const Schema = {
|
|
@@ -176,6 +181,16 @@ export async function handler(
|
|
|
176
181
|
user_id: params.userId,
|
|
177
182
|
});
|
|
178
183
|
break;
|
|
184
|
+
|
|
185
|
+
case "changeFlag":
|
|
186
|
+
await supabase
|
|
187
|
+
.from("profiles")
|
|
188
|
+
.upsert({
|
|
189
|
+
id: params.userId,
|
|
190
|
+
flag: params.flag,
|
|
191
|
+
})
|
|
192
|
+
.select();
|
|
193
|
+
break;
|
|
179
194
|
}
|
|
180
195
|
|
|
181
196
|
// Log the admin action
|