All checks were successful
Test Asgard Runner / test (push) Successful in 2s
- DB migrations 017 (betterchat_configs) and 020 (timedexecute_configs) applied - TypeORM entities matching production schema exactly - NestJS modules with full CRUD + apply-to-server + import-from-server - Pinia stores following teleport config pattern - BetterChatView: Chat Groups editor with color pickers, font sizes, format strings; Settings tab with word filter, anti-flood, player tagging - TimedExecuteView: TimerRepeat with presets, RealTime-Timer, OnConnect/OnDisconnect command lists - Wired into app.module.ts, router, DashboardLayout nav Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81 lines
3.0 KiB
TypeScript
81 lines
3.0 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
|
import { BetterChatService } from './betterchat.service';
|
|
import { CreateBetterChatConfigDto } from './dto/create-betterchat-config.dto';
|
|
import { UpdateBetterChatConfigDto } from './dto/update-betterchat-config.dto';
|
|
import { ImportBetterChatConfigDto } from './dto/import-betterchat-config.dto';
|
|
import { CurrentTenant } from '../../common/decorators/current-tenant.decorator';
|
|
import { RequirePermission } from '../../common/decorators/require-permission.decorator';
|
|
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
|
import { PermissionsGuard } from '../../common/guards/permissions.guard';
|
|
|
|
@ApiTags('betterchat')
|
|
@ApiBearerAuth()
|
|
@Controller('betterchat')
|
|
@UseGuards(JwtAuthGuard, PermissionsGuard)
|
|
export class BetterChatController {
|
|
constructor(private readonly betterChatService: BetterChatService) {}
|
|
|
|
@Get('configs')
|
|
@RequirePermission('betterchat.view')
|
|
@ApiOperation({ summary: 'List BetterChat configs (summaries)' })
|
|
getConfigs(@CurrentTenant() licenseId: string) {
|
|
return this.betterChatService.getConfigs(licenseId);
|
|
}
|
|
|
|
@Get('configs/:id')
|
|
@RequirePermission('betterchat.view')
|
|
@ApiOperation({ summary: 'Get full BetterChat config with data' })
|
|
getConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
|
return this.betterChatService.getConfig(licenseId, id);
|
|
}
|
|
|
|
@Post('configs')
|
|
@RequirePermission('betterchat.manage')
|
|
@ApiOperation({ summary: 'Create BetterChat config' })
|
|
createConfig(@CurrentTenant() licenseId: string, @Body() dto: CreateBetterChatConfigDto) {
|
|
return this.betterChatService.createConfig(licenseId, dto);
|
|
}
|
|
|
|
@Put('configs/:id')
|
|
@RequirePermission('betterchat.manage')
|
|
@ApiOperation({ summary: 'Update BetterChat config' })
|
|
updateConfig(
|
|
@CurrentTenant() licenseId: string,
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateBetterChatConfigDto,
|
|
) {
|
|
return this.betterChatService.updateConfig(licenseId, id, dto);
|
|
}
|
|
|
|
@Delete('configs/:id')
|
|
@RequirePermission('betterchat.manage')
|
|
@ApiOperation({ summary: 'Delete BetterChat config' })
|
|
deleteConfig(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
|
return this.betterChatService.deleteConfig(licenseId, id);
|
|
}
|
|
|
|
@Post('configs/:id/apply')
|
|
@RequirePermission('betterchat.manage')
|
|
@ApiOperation({ summary: 'Deploy BetterChat config to server' })
|
|
applyToServer(@CurrentTenant() licenseId: string, @Param('id') id: string) {
|
|
return this.betterChatService.applyToServer(licenseId, id);
|
|
}
|
|
|
|
@Post('import-from-server')
|
|
@RequirePermission('betterchat.manage')
|
|
@ApiOperation({ summary: 'Import BetterChat.json from server via NATS' })
|
|
importFromServer(@CurrentTenant() licenseId: string, @Body() dto: ImportBetterChatConfigDto) {
|
|
return this.betterChatService.importFromServer(licenseId, dto.config_name, dto.description);
|
|
}
|
|
}
|