Some fixes
This commit is contained in:
parent
e08922a19e
commit
9246816b74
2 changed files with 4 additions and 8 deletions
|
|
@ -30,7 +30,7 @@ const logToCSV = (rayId, ip, hostname, endpoint, useragent, action, country, sef
|
|||
const readReportedIPs = () => {
|
||||
if (!fs.existsSync(CSV_FILE_PATH)) return [];
|
||||
|
||||
const content = fs.readFileSync(CSV_FILE_PATH, 'utf8');
|
||||
const content = fs.readFileSync(CSV_FILE_PATH, 'utf-8');
|
||||
return content
|
||||
.split('\n')
|
||||
.slice(1)
|
||||
|
|
@ -60,7 +60,7 @@ const updateSefinekAPIInCSV = (rayId, reportedToSefinekAPI) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(CSV_FILE_PATH, 'utf8');
|
||||
const content = fs.readFileSync(CSV_FILE_PATH, 'utf-8');
|
||||
const lines = content.split('\n');
|
||||
|
||||
const updatedLines = lines.map(line => {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ const SEFINEK_API_URL = `${process.env.NODE_ENV === 'production' ? 'https://api.
|
|||
module.exports = async () => {
|
||||
const reportedIPs = readReportedIPs().filter(ip => ip.action === 'Reported' && ip.sefinekAPI === 'false');
|
||||
if (reportedIPs.length === 0) {
|
||||
log('info', 'No reported IPs with action "Reported" and SefinekAPI false to send to Sefinek API.');
|
||||
return;
|
||||
return log('info', 'No reported IPs with action "Reported" and SefinekAPI false to send to Sefinek API');
|
||||
}
|
||||
|
||||
const uniqueLogs = reportedIPs.reduce((acc, ip) => {
|
||||
|
|
@ -19,10 +18,7 @@ module.exports = async () => {
|
|||
return acc;
|
||||
}, { seen: new Set(), logs: [] }).logs;
|
||||
|
||||
if (uniqueLogs.length === 0) {
|
||||
log('info', 'No unique IPs to send.');
|
||||
return;
|
||||
}
|
||||
if (uniqueLogs.length === 0) return log('info', 'No unique IPs to send');
|
||||
|
||||
try {
|
||||
const res = await axios.post(SEFINEK_API_URL, {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue