mirror of
https://github.com/misskey-dev/misskey
synced 2024-05-18 01:10:09 +02:00
dddbc1c894
* feat: まず公開できるように (misskey-dev/misskey#10447) * feat: 公開したリストのページを作成 (misskey-dev/misskey#10447) * feat: いいねできるように * feat: インポートに対応 * wip * wip * CHANGELOGを編集 * add note * refactor --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import type { UserListsRepository } from '@/models/index.js';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import { UserListEntityService } from '@/core/entities/UserListEntityService.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
import { ApiError } from '../../../error.js';
|
|
|
|
export const meta = {
|
|
tags: ['lists'],
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'write:account',
|
|
|
|
description: 'Update the properties of a list.',
|
|
|
|
res: {
|
|
type: 'object',
|
|
optional: false, nullable: false,
|
|
ref: 'UserList',
|
|
},
|
|
|
|
errors: {
|
|
noSuchList: {
|
|
message: 'No such list.',
|
|
code: 'NO_SUCH_LIST',
|
|
id: '796666fe-3dff-4d39-becb-8a5932c1d5b7',
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
listId: { type: 'string', format: 'misskey:id' },
|
|
name: { type: 'string', minLength: 1, maxLength: 100 },
|
|
isPublic: { type: 'boolean' },
|
|
},
|
|
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,
|
|
|
|
private userListEntityService: UserListEntityService,
|
|
) {
|
|
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.update(userList.id, {
|
|
name: ps.name,
|
|
isPublic: ps.isPublic,
|
|
});
|
|
|
|
return await this.userListEntityService.pack(userList.id);
|
|
});
|
|
}
|
|
}
|