firefish/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts
ThatOneCalculator 7c2dabd047
no more eslint
2023-01-12 20:54:33 -08:00

30 lines
587 B
TypeScript

import define from "../../define.js";
import { deleteFile } from "@/services/drive/delete-file.js";
import { DriveFiles } from "@/models/index.js";
export const meta = {
tags: ["admin"],
requireCredential: true,
requireModerator: true,
} as const;
export const paramDef = {
type: "object",
properties: {
userId: { type: "string", format: "misskey:id" },
},
required: ["userId"],
} as const;
export default define(meta, paramDef, async (ps, me) => {
const files = await DriveFiles.findBy({
userId: ps.userId,
});
for (const file of files) {
deleteFile(file);
}
});