a07d753da8
* 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>
46 lines
851 B
TypeScript
46 lines
851 B
TypeScript
import $ from 'cafy';
|
|
import { ID } from '../../../../misc/cafy-id';
|
|
import define from '../../define';
|
|
import { ApiError } from '../../error';
|
|
import { Antennas } from '../../../../models';
|
|
|
|
export const meta = {
|
|
desc: {
|
|
'ja-JP': 'アンテナを削除します。',
|
|
'en-US': 'Delete a antenna.'
|
|
},
|
|
|
|
tags: ['antennas'],
|
|
|
|
requireCredential: true as const,
|
|
|
|
kind: 'write:account',
|
|
|
|
params: {
|
|
antennaId: {
|
|
validator: $.type(ID),
|
|
}
|
|
},
|
|
|
|
errors: {
|
|
noSuchAntenna: {
|
|
message: 'No such antenna.',
|
|
code: 'NO_SUCH_ANTENNA',
|
|
id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df'
|
|
}
|
|
}
|
|
};
|
|
|
|
export default define(meta, async (ps, user) => {
|
|
const antenna = await Antennas.findOne({
|
|
id: ps.antennaId,
|
|
userId: user.id
|
|
});
|
|
|
|
if (antenna == null) {
|
|
throw new ApiError(meta.errors.noSuchAntenna);
|
|
}
|
|
|
|
await Antennas.delete(antenna.id);
|
|
});
|