mirror of
https://github.com/misskey-dev/misskey
synced 2024-06-26 04:17:54 +02:00
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import type { UserListsRepository } from '@/models/index.js';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
import { ApiError } from '../../../error.js';
|
|
|
|
export const meta = {
|
|
tags: ['lists'],
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'write:account',
|
|
|
|
description: 'Delete an existing list of users.',
|
|
|
|
errors: {
|
|
noSuchList: {
|
|
message: 'No such list.',
|
|
code: 'NO_SUCH_LIST',
|
|
id: '78436795-db79-42f5-b1e2-55ea2cf19166',
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
listId: { type: 'string', format: 'misskey:id' },
|
|
},
|
|
required: ['listId'],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
@Injectable()
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|
constructor(
|
|
@Inject(DI.userListsRepository)
|
|
private userListsRepository: UserListsRepository,
|
|
) {
|
|
super(meta, paramDef, async (ps, me) => {
|
|
const userList = await this.userListsRepository.findOneBy({
|
|
id: ps.listId,
|
|
userId: me.id,
|
|
});
|
|
|
|
if (userList == null) {
|
|
throw new ApiError(meta.errors.noSuchList);
|
|
}
|
|
|
|
await this.userListsRepository.delete(userList.id);
|
|
});
|
|
}
|
|
}
|