Spaces:
Runtime error
Runtime error
| import { Controller, Put, Param, Body } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger'; | |
| import { ProfileService } from './profile.service'; | |
| import { SetProfileNameDto, SetProfileStatusDto, SetProfilePictureDto } from './dto/profile.dto'; | |
| import { RequireRole } from '../auth/decorators/auth.decorators'; | |
| import { ApiKeyRole } from '../auth/entities/api-key.entity'; | |
| ('profile') | |
| ('sessions/:sessionId/profile') | |
| export class ProfileController { | |
| constructor(private readonly profileService: ProfileService) {} | |
| ('name') | |
| (ApiKeyRole.OPERATOR) | |
| ({ summary: 'Set the account display name' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ type: SetProfileNameDto }) | |
| ({ status: 200, description: 'Profile name updated' }) | |
| ({ status: 400, description: 'Session is not started' }) | |
| ({ status: 403, description: 'The engine refused the name change' }) | |
| async setName(('sessionId') sessionId: string, () dto: SetProfileNameDto) { | |
| await this.profileService.setProfileName(sessionId, dto.name); | |
| return { success: true, message: 'Profile name updated' }; | |
| } | |
| ('status') | |
| (ApiKeyRole.OPERATOR) | |
| ({ summary: 'Set the account about/status text' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ type: SetProfileStatusDto }) | |
| ({ status: 200, description: 'Profile status updated' }) | |
| ({ status: 400, description: 'Session is not started' }) | |
| async setStatus(('sessionId') sessionId: string, () dto: SetProfileStatusDto) { | |
| await this.profileService.setProfileStatus(sessionId, dto.status); | |
| return { success: true, message: 'Profile status updated' }; | |
| } | |
| ('picture') | |
| (ApiKeyRole.OPERATOR) | |
| ({ summary: 'Set the account profile picture (URL or base64 image)' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ type: SetProfilePictureDto }) | |
| ({ status: 200, description: 'Profile picture updated' }) | |
| ({ | |
| status: 400, | |
| description: 'Neither url nor base64 provided, base64 without mimetype, or session is not started', | |
| }) | |
| ({ status: 403, description: 'The engine refused the picture change' }) | |
| ({ status: 413, description: 'Decoded base64 image exceeds the configured media cap' }) | |
| async setPicture(('sessionId') sessionId: string, () dto: SetProfilePictureDto) { | |
| await this.profileService.setProfilePicture(sessionId, dto); | |
| return { success: true, message: 'Profile picture updated' }; | |
| } | |
| } | |