This commit is contained in:
tamaina 2023-06-04 15:07:21 +00:00
parent 7f51ace0ff
commit de9a5d515d
2 changed files with 32 additions and 33 deletions

View File

@ -5,46 +5,17 @@ import { AntennaEntityService } from '@/core/entities/AntennaEntityService.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', 'account'],
requireCredential: true,
kind: 'read:account',
errors: {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b',
},
},
res: {
type: 'object',
optional: false, nullable: false,
ref: 'Antenna',
},
} 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/show'> {
name = 'antennas/show' as const;
constructor( constructor(
@Inject(DI.antennasRepository) @Inject(DI.antennasRepository)
private antennasRepository: AntennasRepository, private antennasRepository: AntennasRepository,
private antennaEntityService: AntennaEntityService, private antennaEntityService: AntennaEntityService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(async (ps, me) => {
// Fetch the antenna // Fetch the antenna
const antenna = await this.antennasRepository.findOneBy({ const antenna = await this.antennasRepository.findOneBy({
id: ps.antennaId, id: ps.antennaId,
@ -52,7 +23,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}); });
if (antenna == null) { if (antenna == null) {
throw new ApiError(meta.errors.noSuchAntenna); throw new ApiError(this.meta.errors.noSuchAntenna);
} }
return await this.antennaEntityService.pack(antenna); return await this.antennaEntityService.pack(antenna);

View File

@ -2114,6 +2114,34 @@ export const endpoints = {
}, },
}], }],
}, },
'antennas/show': {
tags: ['antennas', 'account'],
requireCredential: true,
kind: 'read:account',
errors: {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b',
},
},
defines: [{
req: {
type: 'object',
properties: {
antennaId: { type: 'string', format: 'misskey:id' },
},
required: ['antennaId'],
},
res: {
$ref: 'https://misskey-hub.net/api/schemas/Antenna',
},
}],
},
//#endregion //#endregion
} as const satisfies { [x: string]: IEndpointMeta; }; } as const satisfies { [x: string]: IEndpointMeta; };