iceshrimp/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts
syuilo d2b5b67b44 refactor: refactoring imports
将来ESMに移行しやすいように
Related: #7658

なんかmochaが起動しなくなってるけど理由不明
すぐ直したい
2021-08-19 18:33:41 +09:00

29 lines
543 B
TypeScript

import $ from 'cafy';
import define from '../../define.js';
import { deleteFile } from '@/services/drive/delete-file.js';
import { DriveFiles } from '@/models/index.js';
import { ID } from '@/misc/cafy-id.js';
export const meta = {
tags: ['admin'],
requireCredential: true as const,
requireModerator: true,
params: {
userId: {
validator: $.type(ID),
},
}
};
export default define(meta, async (ps, me) => {
const files = await DriveFiles.find({
userId: ps.userId
});
for (const file of files) {
deleteFile(file);
}
});