fix: use @TenantId() decorator in VoiceConfigController for JWT tenant extraction
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f9c47de04b
commit
e32a3a9800
|
|
@ -5,7 +5,8 @@
|
||||||
* GET /api/v1/agent/voice-config → Get current tenant's voice config
|
* GET /api/v1/agent/voice-config → Get current tenant's voice config
|
||||||
* PUT /api/v1/agent/voice-config → Upsert voice config
|
* PUT /api/v1/agent/voice-config → Upsert voice config
|
||||||
*/
|
*/
|
||||||
import { Controller, Get, Put, Body, Headers } from '@nestjs/common';
|
import { Controller, Get, Put, Body } from '@nestjs/common';
|
||||||
|
import { TenantId } from '@it0/common';
|
||||||
import { VoiceConfigService, UpdateVoiceConfigDto } from '../../../infrastructure/services/voice-config.service';
|
import { VoiceConfigService, UpdateVoiceConfigDto } from '../../../infrastructure/services/voice-config.service';
|
||||||
|
|
||||||
const DEFAULT_CONFIG = {
|
const DEFAULT_CONFIG = {
|
||||||
|
|
@ -17,7 +18,7 @@ export class VoiceConfigController {
|
||||||
constructor(private readonly voiceConfigService: VoiceConfigService) {}
|
constructor(private readonly voiceConfigService: VoiceConfigService) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
async getConfig(@Headers('x-tenant-id') tenantId: string) {
|
async getConfig(@TenantId() tenantId: string) {
|
||||||
if (!tenantId) return DEFAULT_CONFIG;
|
if (!tenantId) return DEFAULT_CONFIG;
|
||||||
const config = await this.voiceConfigService.findByTenantId(tenantId);
|
const config = await this.voiceConfigService.findByTenantId(tenantId);
|
||||||
if (!config) return { ...DEFAULT_CONFIG, tenantId };
|
if (!config) return { ...DEFAULT_CONFIG, tenantId };
|
||||||
|
|
@ -29,7 +30,7 @@ export class VoiceConfigController {
|
||||||
|
|
||||||
@Put()
|
@Put()
|
||||||
async upsertConfig(
|
async upsertConfig(
|
||||||
@Headers('x-tenant-id') tenantId: string,
|
@TenantId() tenantId: string,
|
||||||
@Body() dto: UpdateVoiceConfigDto,
|
@Body() dto: UpdateVoiceConfigDto,
|
||||||
) {
|
) {
|
||||||
const config = await this.voiceConfigService.upsert(tenantId || 'default', dto);
|
const config = await this.voiceConfigService.upsert(tenantId || 'default', dto);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue