This commit is contained in:
tamaina 2023-05-29 14:09:13 +00:00
parent e1b4a0438e
commit 94f25d9cdd
3 changed files with 161 additions and 132 deletions

View file

@ -4,34 +4,17 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import { DeleteAccountService } from '@/core/DeleteAccountService.js';
import { DI } from '@/di-symbols.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
res: {
},
} as const;
export const paramDef = {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/delete-account'> {
name = 'admin/delete-account' as const;
constructor(
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
private deleteAccountService: DeleteAccountService,
) {
super(meta, paramDef, async (ps) => {
super(async (ps) => {
const user = await this.usersRepository.findOneByOrFail({ id: ps.userId });
if (user.isDeleted) {
return;

View file

@ -4,31 +4,17 @@ import type { DriveFilesRepository } from '@/models/index.js';
import { DriveService } from '@/core/DriveService.js';
import { DI } from '@/di-symbols.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
} as const;
export const paramDef = {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/delete-all-files-of-a-user'> {
name = 'admin/delete-all-files-of-a-user' as const;
constructor(
@Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository,
private driveService: DriveService,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
const files = await this.driveFilesRepository.findBy({
userId: ps.userId,
});

View file

@ -455,12 +455,16 @@ export const endpoints = {
req: {
type: 'object',
properties: {
ids: { type: 'array', items: {
ids: {
type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
aliases: { type: 'array', items: {
}
},
aliases: {
type: 'array', items: {
type: 'string',
} },
}
},
},
required: ['ids', 'aliases'],
},
@ -491,15 +495,19 @@ export const endpoints = {
type: ['string', 'null'],
description: 'Use `null` to reset the category.',
},
aliases: { type: 'array', items: {
aliases: {
type: 'array', items: {
type: 'string',
} },
}
},
license: { type: ['string', 'null'] },
isSensitive: { type: 'boolean' },
localOnly: { type: 'boolean' },
roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: {
roleIdsThatCanBeUsedThisEmojiAsReaction: {
type: 'array', items: {
type: 'string',
} },
}
},
},
required: ['name', 'fileId'],
},
@ -553,9 +561,11 @@ export const endpoints = {
req: {
type: 'object',
properties: {
ids: { type: 'array', items: {
ids: {
type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
}
},
},
required: ['ids'],
},
@ -668,12 +678,16 @@ export const endpoints = {
req: {
type: 'object',
properties: {
ids: { type: 'array', items: {
ids: {
type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
aliases: { type: 'array', items: {
}
},
aliases: {
type: 'array', items: {
type: 'string',
} },
}
},
},
required: ['ids', 'aliases'],
},
@ -690,12 +704,16 @@ export const endpoints = {
req: {
type: 'object',
properties: {
ids: { type: 'array', items: {
ids: {
type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
aliases: { type: 'array', items: {
}
},
aliases: {
type: 'array', items: {
type: 'string',
} },
}
},
},
required: ['ids', 'aliases'],
},
@ -712,9 +730,11 @@ export const endpoints = {
req: {
type: 'object',
properties: {
ids: { type: 'array', items: {
ids: {
type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
}
},
category: {
type: ['string', 'null'],
description: 'Use `null` to reset the category.',
@ -735,9 +755,11 @@ export const endpoints = {
req: {
type: 'object',
properties: {
ids: { type: 'array', items: {
ids: {
type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
}
},
license: {
type: ['string', 'null'],
description: 'Use `null` to reset the license.',
@ -773,15 +795,19 @@ export const endpoints = {
type: ['string', 'null'],
description: 'Use `null` to reset the category.',
},
aliases: { type: 'array', items: {
aliases: {
type: 'array', items: {
type: 'string',
} },
}
},
license: { type: ['string', 'null'] },
isSensitive: { type: 'boolean' },
localOnly: { type: 'boolean' },
roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: {
roleIdsThatCanBeUsedThisEmojiAsReaction: {
type: 'array', items: {
type: 'string',
} },
}
},
},
required: ['id', 'name', 'aliases'],
},
@ -1406,6 +1432,40 @@ export const endpoints = {
},
}],
},
'admin/delete-account': {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
defines: [{
req: {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
},
res: undefined,
}],
},
'admin/delete-all-files-of-a-user': {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
defines: [{
req: {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
},
res: undefined,
}],
}
} as const satisfies { [x: string]: IEndpointMeta; };
/**