forked from FoundKeyGang/FoundKey
Johann150
934ee82b8f
The UUIDs are no longer used for errors and all errors should now have a descriptive message attached to them. Also, all errors should now have the proper HTTP status code for a reply instead of the generic 400 and 500 response codes. Because the errors all have more specific error codes, the "kind" of client or server is also abolished.
34 lines
720 B
TypeScript
34 lines
720 B
TypeScript
import { GalleryPosts } from '@/models/index.js';
|
|
import define from '../../../define.js';
|
|
import { ApiError } from '../../../error.js';
|
|
|
|
export const meta = {
|
|
tags: ['gallery'],
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'write:gallery',
|
|
|
|
errors: ['NO_SUCH_POST'],
|
|
} 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
|
|
export default define(meta, paramDef, async (ps, user) => {
|
|
const post = await GalleryPosts.findOneBy({
|
|
id: ps.postId,
|
|
userId: user.id,
|
|
});
|
|
|
|
if (post == null) throw new ApiError('NO_SUCH_POST');
|
|
|
|
await GalleryPosts.delete(post.id);
|
|
});
|