2022-02-27 11:07:39 +09:00
|
|
|
import define from '../../define.js';
|
|
|
|
import { ApiError } from '../../error.js';
|
|
|
|
import { Antennas } from '@/models/index.js';
|
|
|
|
import { publishInternalEvent } from '@/services/stream.js';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['antennas'],
|
|
|
|
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: true,
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
kind: 'write:account',
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
noSuchAntenna: {
|
|
|
|
message: 'No such antenna.',
|
|
|
|
code: 'NO_SUCH_ANTENNA',
|
2021-12-09 23:58:30 +09:00
|
|
|
id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df',
|
|
|
|
},
|
|
|
|
},
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-02-20 13:15:40 +09:00
|
|
|
export const paramDef = {
|
2022-02-19 14:05:32 +09:00
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
antennaId: { type: 'string', format: 'misskey:id' },
|
|
|
|
},
|
|
|
|
required: ['antennaId'],
|
|
|
|
} 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, user) => {
|
2022-03-26 15:34:00 +09:00
|
|
|
const antenna = await Antennas.findOneBy({
|
2020-01-30 04:37:25 +09:00
|
|
|
id: ps.antennaId,
|
2021-12-09 23:58:30 +09:00
|
|
|
userId: user.id,
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
if (antenna == null) {
|
|
|
|
throw new ApiError(meta.errors.noSuchAntenna);
|
|
|
|
}
|
|
|
|
|
|
|
|
await Antennas.delete(antenna.id);
|
2021-03-23 15:06:56 +09:00
|
|
|
|
|
|
|
publishInternalEvent('antennaDeleted', antenna);
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|