refactor
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
f7178f4e32
commit
64e446d1cf
|
@ -25,23 +25,23 @@ module.exports = Self => {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const con = mysql.createConnection({
|
const con = mysql.createConnection({
|
||||||
host: `${config.hostDb}`,
|
host: config.hostDb,
|
||||||
user: `${config.userDb}`,
|
user: config.userDb,
|
||||||
password: `${config.passwordDb}`,
|
password: config.passwordDb,
|
||||||
port: `${config.portDb}`
|
port: config.portDb
|
||||||
});
|
});
|
||||||
|
|
||||||
const sql = `SELECT ot.ticket_id, ot.number
|
const sql = `SELECT ot.ticket_id, ot.number
|
||||||
FROM osticket.ost_ticket ot
|
FROM osticket.ost_ticket ot
|
||||||
JOIN osticket.ost_ticket_status ots ON ots.id = ot.status_id
|
JOIN osticket.ost_ticket_status ots ON ots.id = ot.status_id
|
||||||
JOIN osticket.ost_thread ot2 ON ot2.object_id = ot.ticket_id AND ot2.object_type = 'T'
|
JOIN osticket.ost_thread ot2 ON ot2.object_id = ot.ticket_id AND ot2.object_type = 'T'
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT ote.thread_id, MAX(ote.created) created, MAX(ote.updated) updated
|
SELECT ote.thread_id, MAX(ote.created) created, MAX(ote.updated) updated
|
||||||
FROM osticket.ost_thread_entry ote
|
FROM osticket.ost_thread_entry ote
|
||||||
WHERE ote.staff_id != 0 AND ote.type = 'R'
|
WHERE ote.staff_id AND ote.type = 'R'
|
||||||
GROUP BY ote.thread_id
|
GROUP BY ote.thread_id
|
||||||
) sub ON sub.thread_id = ot2.id
|
) sub ON sub.thread_id = ot2.id
|
||||||
WHERE ot.isanswered = 1
|
WHERE ot.isanswered
|
||||||
AND ots.state = '${config.oldStatus}'
|
AND ots.state = '${config.oldStatus}'
|
||||||
AND IF(sub.updated > sub.created, sub.updated, sub.created) < DATE_SUB(CURDATE(), INTERVAL ${config.day} DAY)`;
|
AND IF(sub.updated > sub.created, sub.updated, sub.created) < DATE_SUB(CURDATE(), INTERVAL ${config.day} DAY)`;
|
||||||
|
|
||||||
|
@ -112,28 +112,34 @@ module.exports = Self => {
|
||||||
|
|
||||||
async function close(token, secondCookie) {
|
async function close(token, secondCookie) {
|
||||||
for (const ticketId of ticketsId) {
|
for (const ticketId of ticketsId) {
|
||||||
const lockCode = await getLockCode(token, secondCookie, ticketId);
|
try {
|
||||||
let form = new FormData();
|
const lockCode = await getLockCode(token, secondCookie, ticketId);
|
||||||
form.append('__CSRFToken__', token);
|
let form = new FormData();
|
||||||
form.append('id', ticketId);
|
form.append('__CSRFToken__', token);
|
||||||
form.append('a', config.responseType);
|
form.append('id', ticketId);
|
||||||
form.append('lockCode', lockCode);
|
form.append('a', config.responseType);
|
||||||
form.append('from_email_id', config.fromEmailId);
|
form.append('lockCode', lockCode);
|
||||||
form.append('reply-to', config.replyTo);
|
form.append('from_email_id', config.fromEmailId);
|
||||||
form.append('cannedResp', 0);
|
form.append('reply-to', config.replyTo);
|
||||||
form.append('response', config.comment);
|
form.append('cannedResp', 0);
|
||||||
form.append('signature', 'none');
|
form.append('response', config.comment);
|
||||||
form.append('reply_status_id', config.newStatusId);
|
form.append('signature', 'none');
|
||||||
|
form.append('reply_status_id', config.newStatusId);
|
||||||
|
|
||||||
const ostUri = `${config.host}/tickets.php?id=${ticketId}`;
|
const ostUri = `${config.host}/tickets.php?id=${ticketId}`;
|
||||||
const params = {
|
const params = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: form,
|
body: form,
|
||||||
headers: {
|
headers: {
|
||||||
'Cookie': secondCookie
|
'Cookie': secondCookie
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return fetch(ostUri, params);
|
await fetch(ostUri, params);
|
||||||
|
} catch (e) {
|
||||||
|
const err = new Error(`${ticketId} Ticket close faildes: ${e.message}`);
|
||||||
|
err.stack += e.stack;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue