mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
Fixed archiving (linereader was broken)
Co-Authored-By: Camdan M <camthehelpdesk@gmail.com>
This commit is contained in:
parent
f8dc04d991
commit
c3f1532bba
5
package-lock.json
generated
5
package-lock.json
generated
@ -1642,6 +1642,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
},
|
},
|
||||||
|
"n-readlines": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/n-readlines/-/n-readlines-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-z4SyAIVgMy7CkgsoNw7YVz40v0g4+WWvvqy8+ZdHrCtgevcEO758WQyrYcw3XPxcLxF+//RszTz/rO48nzD0wQ=="
|
||||||
|
},
|
||||||
"natural-compare": {
|
"natural-compare": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"leekslazylogger": "^2.0.7",
|
"leekslazylogger": "^2.0.7",
|
||||||
"line-reader": "^0.4.0",
|
"line-reader": "^0.4.0",
|
||||||
|
"n-readlines": "^1.0.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"sequelize": "^6.3.5",
|
"sequelize": "^6.3.5",
|
||||||
"terminal-link": "^2.1.1"
|
"terminal-link": "^2.1.1"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
const Logger = require('leekslazylogger');
|
const Logger = require('leekslazylogger');
|
||||||
const log = new Logger();
|
const log = new Logger();
|
||||||
const lineReader = require('line-reader');
|
const Readlines = require('n-readlines');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { join } = require('path');
|
const { join } = require('path');
|
||||||
const dtf = require('@eartharoid/dtf');
|
const dtf = require('@eartharoid/dtf');
|
||||||
@ -117,13 +117,23 @@ module.exports.export = (Ticket, channel) => new Promise((resolve, reject) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
data.messages = [];
|
data.messages = [];
|
||||||
|
let line,
|
||||||
|
lineNumber = 0;
|
||||||
|
|
||||||
lineReader.eachLine(raw, line => {
|
const lineByLine = new Readlines(join(__dirname, raw));
|
||||||
let message = JSON.parse(line);
|
|
||||||
|
// 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);
|
let index = data.messages.findIndex(m => m.id === message.id);
|
||||||
if (index === -1) data.messages.push(message);
|
if (index === -1) data.messages.push(message);
|
||||||
else data.messages[index] = message;
|
else data.messages[index] = message;
|
||||||
}, () => {
|
lineNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.ticket.messages = lineNumber;
|
||||||
|
|
||||||
let endpoint = config.transcripts.web.server;
|
let endpoint = config.transcripts.web.server;
|
||||||
|
|
||||||
if (endpoint[endpoint.length - 1] === '/') endpoint = endpoint.slice(0, -1);
|
if (endpoint[endpoint.length - 1] === '/') endpoint = endpoint.slice(0, -1);
|
||||||
@ -152,6 +162,5 @@ module.exports.export = (Ticket, channel) => new Promise((resolve, reject) => {
|
|||||||
log.warn(e);
|
log.warn(e);
|
||||||
return resolve(e);
|
return resolve(e);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user