mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 07:03:08 +02:00
wip
This commit is contained in:
parent
1f64b7c9ea
commit
93d111bfb6
2 changed files with 30 additions and 27 deletions
|
@ -5,47 +5,24 @@ import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
|
||||||
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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<'antennas/delete'> {
|
||||||
|
name = 'antennas/delete' as const;
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.antennasRepository)
|
@Inject(DI.antennasRepository)
|
||||||
private antennasRepository: AntennasRepository,
|
private antennasRepository: AntennasRepository,
|
||||||
|
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(async (ps, me) => {
|
||||||
const antenna = await this.antennasRepository.findOneBy({
|
const antenna = await this.antennasRepository.findOneBy({
|
||||||
id: ps.antennaId,
|
id: ps.antennaId,
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (antenna == null) {
|
if (antenna == null) {
|
||||||
throw new ApiError(meta.errors.noSuchAntenna);
|
throw new ApiError(this.meta.errors.noSuchAntenna);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.antennasRepository.delete(antenna.id);
|
await this.antennasRepository.delete(antenna.id);
|
||||||
|
|
|
@ -2035,6 +2035,32 @@ export const endpoints = {
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
|
'antennas/delete': {
|
||||||
|
tags: ['antennas'],
|
||||||
|
|
||||||
|
requireCredential: true,
|
||||||
|
|
||||||
|
kind: 'write:account',
|
||||||
|
|
||||||
|
errors: {
|
||||||
|
noSuchAntenna: {
|
||||||
|
message: 'No such antenna.',
|
||||||
|
code: 'NO_SUCH_ANTENNA',
|
||||||
|
id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
defines: [{
|
||||||
|
req: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
antennaId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['antennaId'],
|
||||||
|
},
|
||||||
|
res: undefined,
|
||||||
|
}],
|
||||||
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
} as const satisfies { [x: string]: IEndpointMeta; };
|
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue