improvement: mark ticket messages as read when ticket status change

This commit is contained in:
canove
2020-09-27 09:19:47 -03:00
parent 11f429329b
commit 2d3fa28a58

View File

@@ -1,4 +1,5 @@
import AppError from "../../errors/AppError";
import SetTicketMessagesAsRead from "../../helpers/SetTicketMessagesAsRead";
import Contact from "../../models/Contact";
import Ticket from "../../models/Ticket";
import User from "../../models/User";
@@ -40,6 +41,8 @@ const UpdateTicketService = async ({
throw new AppError("No ticket found with this ID.", 404);
}
await SetTicketMessagesAsRead(ticket);
const oldStatus = ticket.status;
await ticket.update({