fix(housekeeping): address people moderation review
This commit is contained in:
1 parent
29fe22297b
commit
3fa1119f5a
20 files changed
+2000
-777
No files matched your search
+29
-30
@@ -29,6 +29,17 @@ async function execute(
|
||||
);
|
||||
}
|
||||
|
||||
async function executeLegacyModerationAction(
|
||||
staff: { readonly id: number },
|
||||
input: unknown,
|
||||
) {
|
||||
const result = await execute(staff, "moderation.action", input);
|
||||
if (!result.ok) {
|
||||
throw new Error("Could not execute moderation action");
|
||||
}
|
||||
return actionOk();
|
||||
}
|
||||
|
||||
export const assignCfhTicket = adminAction(
|
||||
{ permission: CFH_PERM, schema: cfhIdSchema },
|
||||
async (ctx) => {
|
||||
@@ -85,13 +96,11 @@ const userIdSchema = z.object({ userId: z.coerce.number().int().positive() });
|
||||
|
||||
export const quickKick = adminAction(
|
||||
{ permission: MOD_ACTION_PERM, schema: userIdSchema },
|
||||
async (ctx) => {
|
||||
await execute(ctx.session.user, "moderation.action", {
|
||||
(ctx) =>
|
||||
executeLegacyModerationAction(ctx.session.user, {
|
||||
action: "kick",
|
||||
userId: ctx.data.userId,
|
||||
});
|
||||
return actionOk();
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const muteSchema = z.object({
|
||||
@@ -101,24 +110,20 @@ const muteSchema = z.object({
|
||||
|
||||
export const quickMute = adminAction(
|
||||
{ permission: MOD_ACTION_PERM, schema: muteSchema },
|
||||
async (ctx) => {
|
||||
await execute(ctx.session.user, "moderation.action", {
|
||||
(ctx) =>
|
||||
executeLegacyModerationAction(ctx.session.user, {
|
||||
action: "mute",
|
||||
...ctx.data,
|
||||
});
|
||||
return actionOk();
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
export const quickUnmute = adminAction(
|
||||
{ permission: MOD_ACTION_PERM, schema: userIdSchema },
|
||||
async (ctx) => {
|
||||
await execute(ctx.session.user, "moderation.action", {
|
||||
(ctx) =>
|
||||
executeLegacyModerationAction(ctx.session.user, {
|
||||
action: "unmute",
|
||||
userId: ctx.data.userId,
|
||||
});
|
||||
return actionOk();
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const alertSchema = z.object({
|
||||
@@ -128,26 +133,22 @@ const alertSchema = z.object({
|
||||
|
||||
export const quickAlert = adminAction(
|
||||
{ permission: MOD_ACTION_PERM, schema: alertSchema },
|
||||
async (ctx) => {
|
||||
await execute(ctx.session.user, "moderation.action", {
|
||||
(ctx) =>
|
||||
executeLegacyModerationAction(ctx.session.user, {
|
||||
action: "alert",
|
||||
...ctx.data,
|
||||
});
|
||||
return actionOk();
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const roomIdSchema = z.object({ roomId: z.coerce.number().int().positive() });
|
||||
|
||||
export const quickRoomKick = adminAction(
|
||||
{ permission: MOD_ACTION_PERM, schema: roomIdSchema },
|
||||
async (ctx) => {
|
||||
await execute(ctx.session.user, "moderation.action", {
|
||||
(ctx) =>
|
||||
executeLegacyModerationAction(ctx.session.user, {
|
||||
action: "room-kick",
|
||||
roomId: ctx.data.roomId,
|
||||
});
|
||||
return actionOk();
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const broadcastSchema = z.object({
|
||||
@@ -157,11 +158,9 @@ const broadcastSchema = z.object({
|
||||
|
||||
export const broadcastAlert = adminAction(
|
||||
{ permission: MOD_ACTION_PERM, schema: broadcastSchema },
|
||||
async (ctx) => {
|
||||
await execute(ctx.session.user, "moderation.action", {
|
||||
(ctx) =>
|
||||
executeLegacyModerationAction(ctx.session.user, {
|
||||
action: "broadcast",
|
||||
...ctx.data,
|
||||
});
|
||||
return actionOk();
|
||||
},
|
||||
}),
|
||||
);
|
||||
Reference in new issue
Block a user