mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-29 05:58:04 +09:00
e183c2b509
* Update api document in admin/announcements * Update api document in announcements * Update api document in i/read-announcements * Update api document in username/available * Update api document & Fix typo in API 403 error * Update api document * Update api document * Update api document * Fix API permission definition * Update api document * Update api document * Update api document * Update api document * Update api document * Update api document * Update api document * Update api document * Fix bug in users (api) * Apply reviews #6757 * Apply reviews #6757 Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
83 lines
1.9 KiB
TypeScript
83 lines
1.9 KiB
TypeScript
import $ from 'cafy';
|
|
import define from '../../../define';
|
|
import { Announcements } from '../../../../../models';
|
|
import { genId } from '../../../../../misc/gen-id';
|
|
|
|
export const meta = {
|
|
desc: {
|
|
'ja-JP': 'アナウンスを作成します。',
|
|
'en-US': 'Create a announcement.'
|
|
},
|
|
|
|
tags: ['admin'],
|
|
|
|
requireCredential: true as const,
|
|
requireModerator: true,
|
|
|
|
params: {
|
|
title: {
|
|
validator: $.str.min(1)
|
|
},
|
|
text: {
|
|
validator: $.str.min(1)
|
|
},
|
|
imageUrl: {
|
|
validator: $.nullable.str.min(1)
|
|
}
|
|
},
|
|
|
|
res: {
|
|
type: 'object' as const,
|
|
optional: false as const, nullable: false as const,
|
|
properties: {
|
|
id: {
|
|
type: 'string' as const,
|
|
optional: false as const, nullable: false as const,
|
|
format: 'id',
|
|
description: 'The unique identifier for this Announcement.',
|
|
example: 'xxxxxxxxxx',
|
|
},
|
|
createdAt: {
|
|
type: 'string' as const,
|
|
optional: false as const, nullable: false as const,
|
|
format: 'date-time',
|
|
description: 'The date that the Announcement was created.'
|
|
},
|
|
updatedAt: {
|
|
type: 'string' as const,
|
|
optional: false as const, nullable: true as const,
|
|
format: 'date-time',
|
|
description: 'The date that the Announcement was updated.'
|
|
},
|
|
title: {
|
|
type: 'string' as const,
|
|
optional: false as const, nullable: false as const,
|
|
description: 'Announcement title.'
|
|
},
|
|
text: {
|
|
type: 'string' as const,
|
|
optional: false as const, nullable: false as const,
|
|
description: 'Announcement text.'
|
|
},
|
|
imageUrl: {
|
|
type: 'string' as const,
|
|
optional: false as const, nullable: true as const,
|
|
description: 'Announcement image.'
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
export default define(meta, async (ps) => {
|
|
const announcement = await Announcements.save({
|
|
id: genId(),
|
|
createdAt: new Date(),
|
|
updatedAt: null,
|
|
title: ps.title,
|
|
text: ps.text,
|
|
imageUrl: ps.imageUrl,
|
|
});
|
|
|
|
return announcement;
|
|
});
|