wip gallery

This commit is contained in:
tamaina 2023-07-03 08:57:13 +00:00
parent a97d379c84
commit 41250d997b
10 changed files with 279 additions and 292 deletions

View file

@ -4,45 +4,22 @@ import type { GalleryPostsRepository } from '@/models/index.js';
import { DI } from '@/di-symbols.js';
import { ApiError } from '../../../error.js';
export const meta = {
tags: ['gallery'],
requireCredential: true,
kind: 'write:gallery',
errors: {
noSuchPost: {
message: 'No such post.',
code: 'NO_SUCH_POST',
id: 'ae52f367-4bd7-4ecd-afc6-5672fff427f5',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
postId: { type: 'string', format: 'misskey:id' },
},
required: ['postId'],
} 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<'gallery/posts/delete'> {
name = 'gallery/posts/delete' as const;
constructor(
@Inject(DI.galleryPostsRepository)
private galleryPostsRepository: GalleryPostsRepository,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
const post = await this.galleryPostsRepository.findOneBy({
id: ps.postId,
userId: me.id,
});
if (post == null) {
throw new ApiError(meta.errors.noSuchPost);
throw new ApiError(this.meta.errors.noSuchPost);
}
await this.galleryPostsRepository.delete(post.id);