Update archive.js

This commit is contained in:
Isaac (eartharoid) 2020-11-13 19:57:06 +00:00
parent 8a674c6f07
commit 36f263a07d

View File

@ -117,23 +117,18 @@ module.exports.export = (Ticket, channel) => new Promise((resolve, reject) => {
};
data.messages = [];
let line,
lineNumber = 0;
let line;
const lineByLine = new Readlines(join(__dirname, raw));
// eslint-disable-next-line no-cond-assign
while (line = lineByLine.next()) {
let message = JSON.parse(line.toString('ascii'));
let index = data.messages.findIndex(m => m.id === message.id);
if (index === -1) data.messages.push(message);
else data.messages[index] = message;
lineNumber++;
}
data.ticket.messages = lineNumber;
let endpoint = config.transcripts.web.server;
if (endpoint[endpoint.length - 1] === '/') endpoint = endpoint.slice(0, -1);