wip
This commit is contained in:
parent
e1b4a0438e
commit
94f25d9cdd
3 changed files with 161 additions and 132 deletions
|
@ -4,34 +4,17 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DeleteAccountService } from '@/core/DeleteAccountService.js';
|
import { DeleteAccountService } from '@/core/DeleteAccountService.js';
|
||||||
import { DI } from '@/di-symbols.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@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(
|
constructor(
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
private deleteAccountService: DeleteAccountService,
|
private deleteAccountService: DeleteAccountService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps) => {
|
super(async (ps) => {
|
||||||
const user = await this.usersRepository.findOneByOrFail({ id: ps.userId });
|
const user = await this.usersRepository.findOneByOrFail({ id: ps.userId });
|
||||||
if (user.isDeleted) {
|
if (user.isDeleted) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,31 +4,17 @@ import type { DriveFilesRepository } from '@/models/index.js';
|
||||||
import { DriveService } from '@/core/DriveService.js';
|
import { DriveService } from '@/core/DriveService.js';
|
||||||
import { DI } from '@/di-symbols.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@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(
|
constructor(
|
||||||
@Inject(DI.driveFilesRepository)
|
@Inject(DI.driveFilesRepository)
|
||||||
private driveFilesRepository: DriveFilesRepository,
|
private driveFilesRepository: DriveFilesRepository,
|
||||||
|
|
||||||
private driveService: DriveService,
|
private driveService: DriveService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(async (ps, me) => {
|
||||||
const files = await this.driveFilesRepository.findBy({
|
const files = await this.driveFilesRepository.findBy({
|
||||||
userId: ps.userId,
|
userId: ps.userId,
|
||||||
});
|
});
|
||||||
|
|
|
@ -455,12 +455,16 @@ export const endpoints = {
|
||||||
req: {
|
req: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
ids: { type: 'array', items: {
|
ids: {
|
||||||
type: 'string', format: 'misskey:id',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string', format: 'misskey:id',
|
||||||
aliases: { type: 'array', items: {
|
}
|
||||||
type: 'string',
|
},
|
||||||
} },
|
aliases: {
|
||||||
|
type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['ids', 'aliases'],
|
required: ['ids', 'aliases'],
|
||||||
},
|
},
|
||||||
|
@ -491,15 +495,19 @@ export const endpoints = {
|
||||||
type: ['string', 'null'],
|
type: ['string', 'null'],
|
||||||
description: 'Use `null` to reset the category.',
|
description: 'Use `null` to reset the category.',
|
||||||
},
|
},
|
||||||
aliases: { type: 'array', items: {
|
aliases: {
|
||||||
type: 'string',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string',
|
||||||
|
}
|
||||||
|
},
|
||||||
license: { type: ['string', 'null'] },
|
license: { type: ['string', 'null'] },
|
||||||
isSensitive: { type: 'boolean' },
|
isSensitive: { type: 'boolean' },
|
||||||
localOnly: { type: 'boolean' },
|
localOnly: { type: 'boolean' },
|
||||||
roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: {
|
roleIdsThatCanBeUsedThisEmojiAsReaction: {
|
||||||
type: 'string',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string',
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['name', 'fileId'],
|
required: ['name', 'fileId'],
|
||||||
},
|
},
|
||||||
|
@ -553,9 +561,11 @@ export const endpoints = {
|
||||||
req: {
|
req: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
ids: { type: 'array', items: {
|
ids: {
|
||||||
type: 'string', format: 'misskey:id',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string', format: 'misskey:id',
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['ids'],
|
required: ['ids'],
|
||||||
},
|
},
|
||||||
|
@ -668,12 +678,16 @@ export const endpoints = {
|
||||||
req: {
|
req: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
ids: { type: 'array', items: {
|
ids: {
|
||||||
type: 'string', format: 'misskey:id',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string', format: 'misskey:id',
|
||||||
aliases: { type: 'array', items: {
|
}
|
||||||
type: 'string',
|
},
|
||||||
} },
|
aliases: {
|
||||||
|
type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['ids', 'aliases'],
|
required: ['ids', 'aliases'],
|
||||||
},
|
},
|
||||||
|
@ -690,12 +704,16 @@ export const endpoints = {
|
||||||
req: {
|
req: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
ids: { type: 'array', items: {
|
ids: {
|
||||||
type: 'string', format: 'misskey:id',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string', format: 'misskey:id',
|
||||||
aliases: { type: 'array', items: {
|
}
|
||||||
type: 'string',
|
},
|
||||||
} },
|
aliases: {
|
||||||
|
type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['ids', 'aliases'],
|
required: ['ids', 'aliases'],
|
||||||
},
|
},
|
||||||
|
@ -712,9 +730,11 @@ export const endpoints = {
|
||||||
req: {
|
req: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
ids: { type: 'array', items: {
|
ids: {
|
||||||
type: 'string', format: 'misskey:id',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string', format: 'misskey:id',
|
||||||
|
}
|
||||||
|
},
|
||||||
category: {
|
category: {
|
||||||
type: ['string', 'null'],
|
type: ['string', 'null'],
|
||||||
description: 'Use `null` to reset the category.',
|
description: 'Use `null` to reset the category.',
|
||||||
|
@ -735,9 +755,11 @@ export const endpoints = {
|
||||||
req: {
|
req: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
ids: { type: 'array', items: {
|
ids: {
|
||||||
type: 'string', format: 'misskey:id',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string', format: 'misskey:id',
|
||||||
|
}
|
||||||
|
},
|
||||||
license: {
|
license: {
|
||||||
type: ['string', 'null'],
|
type: ['string', 'null'],
|
||||||
description: 'Use `null` to reset the license.',
|
description: 'Use `null` to reset the license.',
|
||||||
|
@ -773,15 +795,19 @@ export const endpoints = {
|
||||||
type: ['string', 'null'],
|
type: ['string', 'null'],
|
||||||
description: 'Use `null` to reset the category.',
|
description: 'Use `null` to reset the category.',
|
||||||
},
|
},
|
||||||
aliases: { type: 'array', items: {
|
aliases: {
|
||||||
type: 'string',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string',
|
||||||
|
}
|
||||||
|
},
|
||||||
license: { type: ['string', 'null'] },
|
license: { type: ['string', 'null'] },
|
||||||
isSensitive: { type: 'boolean' },
|
isSensitive: { type: 'boolean' },
|
||||||
localOnly: { type: 'boolean' },
|
localOnly: { type: 'boolean' },
|
||||||
roleIdsThatCanBeUsedThisEmojiAsReaction: { type: 'array', items: {
|
roleIdsThatCanBeUsedThisEmojiAsReaction: {
|
||||||
type: 'string',
|
type: 'array', items: {
|
||||||
} },
|
type: 'string',
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: ['id', 'name', 'aliases'],
|
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; };
|
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue