2022-02-27 11:07:39 +09:00
|
|
|
import define from '../../../define.js';
|
|
|
|
import { ApiError } from '../../../error.js';
|
|
|
|
import { GalleryPosts } from '@/models/index.js';
|
2021-04-24 22:38:24 +09:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['gallery'],
|
|
|
|
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: false,
|
2021-04-24 22:38:24 +09:00
|
|
|
|
|
|
|
errors: {
|
|
|
|
noSuchPost: {
|
|
|
|
message: 'No such post.',
|
|
|
|
code: 'NO_SUCH_POST',
|
2021-12-09 23:58:30 +09:00
|
|
|
id: '1137bf14-c5b0-4604-85bb-5b5371b1cd45',
|
2021-04-24 22:38:24 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
res: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
optional: false, nullable: false,
|
2021-12-09 23:58:30 +09:00
|
|
|
ref: 'GalleryPost',
|
|
|
|
},
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2021-04-24 22:38:24 +09:00
|
|
|
|
2022-02-20 13:15:40 +09:00
|
|
|
export const paramDef = {
|
2022-02-19 14:05:32 +09:00
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
postId: { type: 'string', format: 'misskey:id' },
|
|
|
|
},
|
|
|
|
required: ['postId'],
|
|
|
|
} as const;
|
|
|
|
|
2022-01-03 02:12:50 +09:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-02-19 14:05:32 +09:00
|
|
|
export default define(meta, paramDef, async (ps, me) => {
|
2021-04-24 22:38:24 +09:00
|
|
|
const post = await GalleryPosts.findOne({
|
|
|
|
id: ps.postId,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (post == null) {
|
|
|
|
throw new ApiError(meta.errors.noSuchPost);
|
|
|
|
}
|
|
|
|
|
|
|
|
return await GalleryPosts.pack(post, me);
|
|
|
|
});
|