diff --git a/src/comentarios/comentarios.controller.ts b/src/comentarios/comentarios.controller.ts index b38d3b4..81f19c8 100644 --- a/src/comentarios/comentarios.controller.ts +++ b/src/comentarios/comentarios.controller.ts @@ -40,4 +40,4 @@ import { return this.comentariosService.deleteComentario(id); } } - \ No newline at end of file + diff --git a/src/comentarios/comentarios.service.ts b/src/comentarios/comentarios.service.ts index f654940..a47965d 100644 --- a/src/comentarios/comentarios.service.ts +++ b/src/comentarios/comentarios.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { BadRequestException, Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Comentarios } from './entity/comentarios.entity'; import { Repository } from 'typeorm'; @@ -12,6 +12,11 @@ export class ComentariosService { ) {} postComentario(comentario: ComentarioDto) { + if (comentario.from !== 'CEDETEC' && comentario.from !== 'PCPUMA') { + throw new BadRequestException('Mensaje no autorizado'); + } + + const nuevoComentario = this.comentariosRepository.create(comentario); return this.comentariosRepository.save(nuevoComentario); } @@ -35,11 +40,15 @@ export class ComentariosService { } if (after) { - query.andWhere('comentarios.fecha_registro > :after', { after: new Date(after) }); + query.andWhere('comentarios.fecha_registro > :after', { + after: new Date(after), + }); } if (from) { - query.andWhere('comentarios.fecha_registro >= :from', { from: new Date(from) }); + query.andWhere('comentarios.fecha_registro >= :from', { + from: new Date(from), + }); } if (to) {