38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { Body, Controller, Get, Post, Put, Req, UseGuards } from '@nestjs/common';
|
|
import { Request } from 'express';
|
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
|
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
import { Roles } from '../auth/decorators/roles.decorator';
|
|
import { RolesGuard } from '../auth/guards/roles.guard';
|
|
import { TenantGuard } from '../auth/guards/tenant.guard';
|
|
import { JwtPayload } from '../auth/types/jwt-payload.type';
|
|
import { TestarEnvioEmailDto } from './dto/testar-envio-email.dto';
|
|
import { UpdateTenantEmailConfigDto } from './dto/update-tenant-email-config.dto';
|
|
import { TenantEmailConfigService } from './tenant-email-config.service';
|
|
|
|
@UseGuards(JwtAuthGuard, TenantGuard, RolesGuard)
|
|
@Roles('tenant_admin')
|
|
@Controller('tenant/email-config')
|
|
export class TenantEmailConfigController {
|
|
constructor(private readonly tenantEmailConfigService: TenantEmailConfigService) {}
|
|
|
|
@Get()
|
|
obter() {
|
|
return this.tenantEmailConfigService.obter();
|
|
}
|
|
|
|
@Put()
|
|
atualizar(
|
|
@Body() dto: UpdateTenantEmailConfigDto,
|
|
@CurrentUser() user: JwtPayload,
|
|
@Req() req: Request,
|
|
) {
|
|
return this.tenantEmailConfigService.atualizar(dto, user, req.ip);
|
|
}
|
|
|
|
@Post('testar-envio')
|
|
testarEnvio(@Body() dto: TestarEnvioEmailDto, @CurrentUser() user: JwtPayload) {
|
|
return this.tenantEmailConfigService.testarEnvio(user, dto);
|
|
}
|
|
}
|