fix: remove ticket from all users when deleted

This commit is contained in:
canove
2020-09-25 21:17:41 -03:00
parent 6c63abf29c
commit eb23775948
7 changed files with 25 additions and 12 deletions

View File

@@ -27,7 +27,7 @@ const UpdateContactService = async ({
const contact = await Contact.findOne({
where: { id: contactId },
attributes: ["id", "name", "number", "email"],
attributes: ["id", "name", "number", "email", "profilePicUrl"],
include: ["extraInfo"]
});

View File

@@ -22,7 +22,7 @@ const CreateMessageService = async ({
const ticket = await ShowTicketService(ticketId);
if (!ticket) {
throw new AppError("No ticket found with this ID");
throw new AppError("No ticket found with this ID", 404);
}
const message: Message = await ticket.$create("message", messageData);

View File

@@ -1,4 +1,5 @@
import { where, fn, col } from "sequelize";
import AppError from "../../errors/AppError";
import Message from "../../models/Message";
import Ticket from "../../models/Ticket";
import ShowTicketService from "../TicketServices/ShowTicketService";
@@ -24,7 +25,7 @@ const ListMessagesService = async ({
const ticket = await ShowTicketService(ticketId);
if (!ticket) {
throw new Error("No ticket found with this ID");
throw new AppError("No ticket found with this ID", 404);
}
const whereCondition = {

View File

@@ -21,7 +21,7 @@ const ShowTicketService = async (id: string | number): Promise<Ticket> => {
});
if (!ticket) {
throw new AppError("No ticket found with this ID");
throw new AppError("No ticket found with this ID", 404);
}
return ticket;