wip
This commit is contained in:
		
							parent
							
								
									1f64b7c9ea
								
							
						
					
					
						commit
						93d111bfb6
					
				|  | @ -5,47 +5,24 @@ import { GlobalEventService } from '@/core/GlobalEventService.js'; | |||
| import { DI } from '@/di-symbols.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
 | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| export default class extends Endpoint<'antennas/delete'> { | ||||
| 	name = 'antennas/delete' as const; | ||||
| 	constructor( | ||||
| 		@Inject(DI.antennasRepository) | ||||
| 		private antennasRepository: AntennasRepository, | ||||
| 
 | ||||
| 		private globalEventService: GlobalEventService, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 		super(async (ps, me) => { | ||||
| 			const antenna = await this.antennasRepository.findOneBy({ | ||||
| 				id: ps.antennaId, | ||||
| 				userId: me.id, | ||||
| 			}); | ||||
| 
 | ||||
| 			if (antenna == null) { | ||||
| 				throw new ApiError(meta.errors.noSuchAntenna); | ||||
| 				throw new ApiError(this.meta.errors.noSuchAntenna); | ||||
| 			} | ||||
| 
 | ||||
| 			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
 | ||||
| } as const satisfies { [x: string]: IEndpointMeta; }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue