ticket bug
This commit is contained in:
@@ -75,7 +75,7 @@ export class TicketRepository extends EntityRepository<Ticket> {
|
|||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
orderBy: { [orderBy]: order.toLowerCase() as 'asc' | 'desc' },
|
orderBy: { [orderBy]: order.toLowerCase() as 'asc' | 'desc' },
|
||||||
populate: ['parent', 'children', 'admin', 'user'],
|
populate: ['admin', 'user'],
|
||||||
filters: ['notDeleted'],
|
filters: ['notDeleted'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ export class TicketController {
|
|||||||
@Post('public/tickets')
|
@Post('public/tickets')
|
||||||
@UseGuards(AuthGuard)
|
@UseGuards(AuthGuard)
|
||||||
@ApiOperation({ summary: 'Create a ticket (as user)' })
|
@ApiOperation({ summary: 'Create a ticket (as user)' })
|
||||||
createAsUser(@Body() createTicketUserDto: CreateTicketUserDto, @UserId() userId: string) {
|
createAsUser(@Body() dto: CreateTicketUserDto, @UserId() userId: string) {
|
||||||
return this.ticketService.createAsUser(createTicketUserDto, userId);
|
return this.ticketService.createTicketAsUser(dto, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('public/tickets')
|
@Get('public/tickets')
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ export class TicketService {
|
|||||||
return ticket;
|
return ticket;
|
||||||
}
|
}
|
||||||
|
|
||||||
async createAsUser(createTicketUserDto: CreateTicketUserDto, userId: string) {
|
async createTicketAsUser(dto: CreateTicketUserDto, userId: string) {
|
||||||
const user = await this.em.findOne(User, { id: userId });
|
const user = await this.em.findOne(User, { id: userId });
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new NotFoundException('User not found');
|
throw new NotFoundException('User not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { parentId, ...rest } = createTicketUserDto;
|
const { parentId, ...rest } = dto;
|
||||||
|
|
||||||
let parent: Ticket | null = null;
|
let parent: Ticket | null = null;
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
@@ -106,9 +106,9 @@ export class TicketService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findTicketMessagesAsUser(ticketId: string, userId: string) {
|
async findTicketMessagesAsUser(ticketId: string, userId: string) {
|
||||||
const ticket = await this.ticketRepository.find(
|
const ticket = await this.ticketRepository.findOne(
|
||||||
{ parent: { id: ticketId }, user: { id: userId } },
|
{ id: ticketId, user: { id: userId } },
|
||||||
{ populate: ['admin', 'user'], filters: ['notDeleted'] },
|
{ populate: ['children', 'children.admin', 'children.user', 'admin', 'user'], filters: ['notDeleted'] },
|
||||||
);
|
);
|
||||||
if (!ticket) {
|
if (!ticket) {
|
||||||
throw new NotFoundException('Ticket not found');
|
throw new NotFoundException('Ticket not found');
|
||||||
@@ -117,9 +117,9 @@ export class TicketService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findTicketMessagesAsAdmin(ticketId: string) {
|
async findTicketMessagesAsAdmin(ticketId: string) {
|
||||||
const ticket = await this.ticketRepository.find(
|
const ticket = await this.ticketRepository.findOne(
|
||||||
{ parent: { id: ticketId } },
|
{ id: ticketId },
|
||||||
{ populate: ['admin', 'user'], filters: ['notDeleted'] },
|
{ populate: ['children', 'children.admin', 'children.user', 'admin', 'user'], filters: ['notDeleted'] },
|
||||||
);
|
);
|
||||||
if (!ticket) {
|
if (!ticket) {
|
||||||
throw new NotFoundException('Ticket not found');
|
throw new NotFoundException('Ticket not found');
|
||||||
|
|||||||
Reference in New Issue
Block a user