mirror of
https://github.com/misskey-dev/misskey.git
synced 2025-01-11 01:00:07 +09:00
fcfb5ef0a3
* wip
* ✌️
* use ajv/dist/core
* revert try
* clean up
45 lines
956 B
TypeScript
45 lines
956 B
TypeScript
import define from '../../define';
|
|
import { ApiError } from '../../error';
|
|
import { Antennas } from '@/models/index';
|
|
import { publishInternalEvent } from '@/services/stream';
|
|
|
|
export const meta = {
|
|
tags: ['antennas'],
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'write:account',
|
|
|
|
errors: {
|
|
noSuchAntenna: {
|
|
message: 'No such antenna.',
|
|
code: 'NO_SUCH_ANTENNA',
|
|
id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df',
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
antennaId: { type: 'string', format: 'misskey:id' },
|
|
},
|
|
required: ['antennaId'],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default define(meta, paramDef, 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);
|
|
|
|
publishInternalEvent('antennaDeleted', antenna);
|
|
});
|