| 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | Delete, |
| 5 | Get, |
| 6 | HttpCode, |
| 7 | HttpStatus, |
| 8 | Param, |
| 9 | Post, |
| 10 | Session, |
| 11 | } from '@nestjs/common'; |
| 12 | import { |
| 13 | ApiBadRequestResponse, |
| 14 | ApiConflictResponse, |
| 15 | ApiCreatedResponse, |
| 16 | ApiNoContentResponse, |
| 17 | ApiNotFoundResponse, |
| 18 | ApiOkResponse, |
| 19 | ApiOperation, |
| 20 | ApiTags, |
| 21 | } from '@nestjs/swagger'; |
| 22 | import type { UserSession |
| 23 | |
| 24 | import { ErrorResponseDTO } |
| 25 | import { |
| 26 | AddGpgKeyDTO, |
| 27 | GpgKeyDTO, |
| 28 | ListGpgKeysResponseDTO, |
| 29 | } from './dto/gpg-key.dto.js'; |
| 30 | import { GpgKeysService } |
| 31 | |
| 32 | @ApiTags('GPG keys') |
| 33 | @Controller('gpg-keys') |
| 34 | export class GpgKeysController |
| 35 | constructor(private readonly |
| 36 | |
| 37 | @Get() |
| 38 | @ApiOperation({ summary |
| 39 | @ApiOkResponse({ type |
| 40 | list(@Session() |
| 41 | return this.keys |
| 42 | } |
| 43 | |
| 44 | @Post() |
| 45 | @ApiOperation({ |
| 46 | summary: 'Add a public key to the signed-in account', |
| 47 | description: |
| 48 | 'Commits signed with it read as verified once the key carries an address this account has verified.', |
| 49 | }) |
| 50 | @ApiCreatedResponse({ type |
| 51 | @ApiBadRequestResponse({ type |
| 52 | @ApiConflictResponse({ type |
| 53 | add(@Session() |
| 54 | return this.keys |
| 55 | } |
| 56 | |
| 57 | @Delete(':id' |
| 58 | @HttpCode(HttpStatus. |
| 59 | @ApiOperation({ |
| 60 | summary: 'Remove a key', |
| 61 | description: |
| 62 | 'Commits it signed stop reading as verified; nothing about the commits themselves changes.', |
| 63 | }) |
| 64 | @ApiNoContentResponse() |
| 65 | @ApiNotFoundResponse({ type |
| 66 | remove(@Session() |
| 67 | return this.keys |
| 68 | } |
| 69 | } |