improvement: change code execution order in some services

This commit is contained in:
canove
2020-09-24 14:27:11 -03:00
parent e1db12d545
commit 0729f25295
2 changed files with 15 additions and 15 deletions

View File

@@ -21,6 +21,12 @@ const ListMessagesService = async ({
pageNumber = "1",
ticketId
}: Request): Promise<Response> => {
const ticket = await ShowTicketService(ticketId);
if (!ticket) {
throw new Error("No ticket found with this ID");
}
const whereCondition = {
body: where(
fn("LOWER", col("body")),
@@ -30,12 +36,6 @@ const ListMessagesService = async ({
ticketId
};
const ticket = await ShowTicketService(ticketId);
if (!ticket) {
throw new Error("No ticket found with this ID");
}
// await setMessagesAsRead(ticket);
const limit = 20;
const offset = limit * (+pageNumber - 1);