435b0e7806
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { Body, Controller, Delete, Get, Post, Put, UseGuards } from '@nestjs/common';
|
|
import { DigestService } from './digest.service';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { RolesGuard } from '../auth/roles.guard';
|
|
import { Roles } from '../auth/roles.decorator';
|
|
import { CurrentTenantContext } from '../auth/current-tenant.decorator';
|
|
import { TenantContext } from '../../common/tenant-context';
|
|
import { UpdateDigestConfigDto } from './digest.dto';
|
|
|
|
@Controller('admin/digest')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('OWNER', 'ADMIN')
|
|
export class DigestController {
|
|
constructor(private readonly digestService: DigestService) {}
|
|
|
|
@Get('config')
|
|
getConfig(@CurrentTenantContext() ctx: TenantContext) {
|
|
return this.digestService.getConfig(ctx.tenantId);
|
|
}
|
|
|
|
@Put('config')
|
|
upsertConfig(
|
|
@CurrentTenantContext() ctx: TenantContext,
|
|
@Body() body: UpdateDigestConfigDto,
|
|
) {
|
|
return this.digestService.upsertConfig(ctx.tenantId, body, ctx.adminId ?? 'unknown');
|
|
}
|
|
|
|
@Delete('config')
|
|
disableConfig(@CurrentTenantContext() ctx: TenantContext) {
|
|
return this.digestService.disableConfig(ctx.tenantId);
|
|
}
|
|
|
|
@Get('history')
|
|
getHistory(@CurrentTenantContext() ctx: TenantContext) {
|
|
return this.digestService.getHistory(ctx.tenantId);
|
|
}
|
|
|
|
@Post('send-now')
|
|
sendNow(@CurrentTenantContext() ctx: TenantContext) {
|
|
return this.digestService.sendNow(ctx.tenantId, ctx.adminId ?? 'unknown');
|
|
}
|
|
}
|