MASTER_4943-osticket_closeTicket #1242
|
@ -97,13 +97,17 @@ module.exports = Self => {
|
||||||
async function close(token, secondCookie) {
|
async function close(token, secondCookie) {
|
||||||
for (const ticketId of ticketsId) {
|
for (const ticketId of ticketsId) {
|
||||||
try {
|
try {
|
||||||
const lockCode = await getLockCode(token, secondCookie, ticketId);
|
const lock = await getLockCode(token, secondCookie, ticketId);
|
||||||
if (!lockCode) throw new Error(`Can't get lock code`);
|
if (!lock.code) {
|
||||||
|
let error = `Can't get lock code`;
|
||||||
|
if (lock.msg) error += `: ${lock.msg}`;
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
let form = new FormData();
|
let form = new FormData();
|
||||||
form.append('__CSRFToken__', token);
|
form.append('__CSRFToken__', token);
|
||||||
form.append('id', ticketId);
|
form.append('id', ticketId);
|
||||||
form.append('a', config.responseType);
|
form.append('a', config.responseType);
|
||||||
form.append('lockCode', lockCode);
|
form.append('lockCode', lock.code);
|
||||||
form.append('from_email_id', config.fromEmailId);
|
form.append('from_email_id', config.fromEmailId);
|
||||||
form.append('reply-to', config.replyTo);
|
form.append('reply-to', config.replyTo);
|
||||||
form.append('cannedResp', 0);
|
form.append('cannedResp', 0);
|
||||||
|
@ -141,7 +145,7 @@ module.exports = Self => {
|
||||||
const body = await response.text();
|
const body = await response.text();
|
||||||
const json = JSON.parse(body);
|
const json = JSON.parse(body);
|
||||||
|
|
||||||
return json.code || null;
|
return json;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue