| 1 | import { Controller, Get, Param, Query, Session } from '@nestjs/common'; |
| 2 | import { |
| 3 | ApiNotFoundResponse, |
| 4 | ApiOkResponse, |
| 5 | ApiOperation, |
| 6 | ApiTags, |
| 7 | } from '@nestjs/swagger'; |
| 8 | import { OptionalAuth, type |
| 9 | |
| 10 | import { ErrorResponseDTO } |
| 11 | import { |
| 12 | SuggestedIssuesResponseDTO, |
| 13 | SuggestedUsersResponseDTO, |
| 14 | SuggestionQueryDTO, |
| 15 | } from './dto/suggestion.dto.js'; |
| 16 | import { SuggestionsService } |
| 17 | |
| 18 | @Controller('repositories/:username/:repo/suggestions') |
| 19 | @ApiTags('Issues') |
| 20 | export class SuggestionsController |
| 21 | constructor(private readonly |
| 22 | |
| 23 | @Get('users' |
| 24 | @OptionalAuth() |
| 25 | @ApiOperation({ |
| 26 | summary: 'Suggest people to mention or assign', |
| 27 | description: |
| 28 | 'Up to eight users whose username starts with `q`, people involved in the repository first.', |
| 29 | }) |
| 30 | @ApiOkResponse({ type |
| 31 | @ApiNotFoundResponse({ type |
| 32 | suggestUsers( |
| 33 | @Param('username' |
| 34 | @Param('repo' |
| 35 | @Query() query |
| 36 | @Session() session |
| 37 | ) { |
| 38 | return this.suggestions |
| 39 | username, |
| 40 | repo, |
| 41 | requesterId: session?.user |
| 42 | q: query.q |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | @Get('issues' |
| 47 | @OptionalAuth() |
| 48 | @ApiOperation({ |
| 49 | summary: 'Suggest issues and pull requests to reference', |
| 50 | description: |
| 51 | 'Up to eight, newest first, whose number starts with `q` or whose title contains it.', |
| 52 | }) |
| 53 | @ApiOkResponse({ type |
| 54 | @ApiNotFoundResponse({ type |
| 55 | suggestIssues( |
| 56 | @Param('username' |
| 57 | @Param('repo' |
| 58 | @Query() query |
| 59 | @Session() session |
| 60 | ) { |
| 61 | return this.suggestions |
| 62 | username, |
| 63 | repo, |
| 64 | requesterId: session?.user |
| 65 | q: query.q |
| 66 | }); |
| 67 | } |
| 68 | } |