feat: update tickets list on transfer

This commit is contained in:
canove
2020-10-24 19:01:04 -03:00
parent c0611916e7
commit 65deab09b4
5 changed files with 16 additions and 14 deletions

View File

@@ -17,8 +17,8 @@ interface Request {
interface Response {
ticket: Ticket;
ticketUser: User | null;
oldStatus: string;
oldUserId: number | undefined;
}
const UpdateTicketService = async ({
@@ -34,6 +34,11 @@ const UpdateTicketService = async ({
model: Contact,
as: "contact",
attributes: ["id", "name", "number", "profilePicUrl"]
},
{
model: User,
as: "user",
attributes: ["id", "name"]
}
]
});
@@ -45,6 +50,7 @@ const UpdateTicketService = async ({
await SetTicketMessagesAsRead(ticket);
const oldStatus = ticket.status;
const oldUserId = ticket.user?.id;
if (oldStatus === "closed") {
await CheckContactOpenTickets(ticket.contact.id);
@@ -54,9 +60,10 @@ const UpdateTicketService = async ({
status,
userId
});
const ticketUser = await ticket.$get("user", { attributes: ["id", "name"] });
return { ticket, oldStatus, ticketUser };
await ticket.reload();
return { ticket, oldStatus, oldUserId };
};
export default UpdateTicketService;