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 = () => {
|
const readReportedIPs = () => {
|
||||||
if (!fs.existsSync(CSV_FILE_PATH)) return [];
|
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
|
return content
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.slice(1)
|
.slice(1)
|
||||||
|
|
@ -60,7 +60,7 @@ const updateSefinekAPIInCSV = (rayId, reportedToSefinekAPI) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = fs.readFileSync(CSV_FILE_PATH, 'utf8');
|
const content = fs.readFileSync(CSV_FILE_PATH, 'utf-8');
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
|
|
||||||
const updatedLines = lines.map(line => {
|
const updatedLines = lines.map(line => {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ const SEFINEK_API_URL = `${process.env.NODE_ENV === 'production' ? 'https://api.
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
const reportedIPs = readReportedIPs().filter(ip => ip.action === 'Reported' && ip.sefinekAPI === 'false');
|
const reportedIPs = readReportedIPs().filter(ip => ip.action === 'Reported' && ip.sefinekAPI === 'false');
|
||||||
if (reportedIPs.length === 0) {
|
if (reportedIPs.length === 0) {
|
||||||
log('info', 'No reported IPs with action "Reported" and SefinekAPI false to send to Sefinek API.');
|
return log('info', 'No reported IPs with action "Reported" and SefinekAPI false to send to Sefinek API');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const uniqueLogs = reportedIPs.reduce((acc, ip) => {
|
const uniqueLogs = reportedIPs.reduce((acc, ip) => {
|
||||||
|
|
@ -19,10 +18,7 @@ module.exports = async () => {
|
||||||
return acc;
|
return acc;
|
||||||
}, { seen: new Set(), logs: [] }).logs;
|
}, { seen: new Set(), logs: [] }).logs;
|
||||||
|
|
||||||
if (uniqueLogs.length === 0) {
|
if (uniqueLogs.length === 0) return log('info', 'No unique IPs to send');
|
||||||
log('info', 'No unique IPs to send.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await axios.post(SEFINEK_API_URL, {
|
const res = await axios.post(SEFINEK_API_URL, {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue