From 201987fb992ac35220eef9d366ece37ff71228c2 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 9 Jan 2023 11:42:16 +0100 Subject: [PATCH] feat: muestra el error --- back/methods/osticket/closeTicket.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/back/methods/osticket/closeTicket.js b/back/methods/osticket/closeTicket.js index 98ef0aeef..40c0d860c 100644 --- a/back/methods/osticket/closeTicket.js +++ b/back/methods/osticket/closeTicket.js @@ -97,13 +97,17 @@ module.exports = Self => { async function close(token, secondCookie) { for (const ticketId of ticketsId) { try { - const lockCode = await getLockCode(token, secondCookie, ticketId); - if (!lockCode) throw new Error(`Can't get lock code`); + const lock = await getLockCode(token, secondCookie, ticketId); + if (!lock.code) { + let error = `Can't get lock code`; + if (lock.msg) error += `: ${lock.msg}`; + throw new Error(error); + } let form = new FormData(); form.append('__CSRFToken__', token); form.append('id', ticketId); form.append('a', config.responseType); - form.append('lockCode', lockCode); + form.append('lockCode', lock.code); form.append('from_email_id', config.fromEmailId); form.append('reply-to', config.replyTo); form.append('cannedResp', 0); @@ -141,7 +145,7 @@ module.exports = Self => { const body = await response.text(); const json = JSON.parse(body); - return json.code || null; + return json; } }; };