Updated packages to remove vulnerabilities reported by npm
Implementation of feedcheck - not tested though
This commit is contained in:
parent
d74806dde3
commit
130c953d94
21 changed files with 4945 additions and 2142 deletions
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
};
|
||||
|
||||
function spawn(callback) {
|
||||
log.info('Executor', 'Spawning executor process.');
|
||||
log.info('Executor', 'Spawning executor process');
|
||||
|
||||
executorProcess = fork(path.join(__dirname, '..', 'services', 'executor.js'), [], {
|
||||
cwd: path.join(__dirname, '..'),
|
||||
|
@ -54,7 +54,7 @@ function spawn(callback) {
|
|||
});
|
||||
|
||||
executorProcess.on('close', (code, signal) => {
|
||||
log.info('Executor', 'Executor process exited with code %s signal %s.', code, signal);
|
||||
log.info('Executor', 'Executor process exited with code %s signal %s', code, signal);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
68
lib/feed.js
68
lib/feed.js
|
@ -1,68 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
let FeedParser = require('feedparser');
|
||||
let request = require('request');
|
||||
let _ = require('./translate')._;
|
||||
let util = require('util');
|
||||
|
||||
module.exports.fetch = (url, callback) => {
|
||||
let req = request(url);
|
||||
let feedparser = new FeedParser();
|
||||
let returned = false;
|
||||
let entries = [];
|
||||
|
||||
req.setHeader('user-agent', 'Mailtrain');
|
||||
req.setHeader('accept', 'text/html,application/xhtml+xml');
|
||||
|
||||
req.on('error', err => {
|
||||
if (returned) {
|
||||
return;
|
||||
}
|
||||
returned = true;
|
||||
callback(err);
|
||||
});
|
||||
|
||||
req.on('response', res => {
|
||||
if (returned) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
return req.emit('error', new Error(util.format(_('Bad status code %s'), res.statusCode)));
|
||||
}
|
||||
|
||||
req.pipe(feedparser);
|
||||
});
|
||||
|
||||
feedparser.on('error', err => {
|
||||
if (returned) {
|
||||
return;
|
||||
}
|
||||
returned = true;
|
||||
callback(err);
|
||||
});
|
||||
|
||||
feedparser.on('readable', () => {
|
||||
let item;
|
||||
while ((item = feedparser.read())) {
|
||||
let entry = {
|
||||
title: item.title,
|
||||
date: item.date || item.pubdate || item.pubDate || new Date(),
|
||||
guid: item.guid || item.link,
|
||||
link: item.link,
|
||||
content: item.description || item.summary,
|
||||
summary: item.summary || item.description,
|
||||
image_url: item.image.url
|
||||
};
|
||||
entries.push(entry);
|
||||
}
|
||||
});
|
||||
|
||||
feedparser.on('end', () => {
|
||||
if (returned) {
|
||||
return;
|
||||
}
|
||||
returned = true;
|
||||
callback(null, entries);
|
||||
});
|
||||
};
|
33
lib/feedcheck.js
Normal file
33
lib/feedcheck.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
const fork = require('child_process').fork;
|
||||
const log = require('npmlog');
|
||||
const path = require('path');
|
||||
|
||||
let feedcheckProcess;
|
||||
|
||||
module.exports = {
|
||||
spawn
|
||||
};
|
||||
|
||||
function spawn(callback) {
|
||||
log.info('Feed', 'Spawning feedcheck process');
|
||||
|
||||
feedcheckProcess = fork(path.join(__dirname, '..', 'services', 'feedcheck.js'), [], {
|
||||
cwd: path.join(__dirname, '..'),
|
||||
env: {NODE_ENV: process.env.NODE_ENV}
|
||||
});
|
||||
|
||||
feedcheckProcess.on('message', msg => {
|
||||
if (msg) {
|
||||
if (msg.type === 'feedcheck-started') {
|
||||
log.info('Feed', 'Feedcheck process started');
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
feedcheckProcess.on('close', (code, signal) => {
|
||||
log.error('Feed', 'Feedcheck process exited with code %s signal %s', code, signal);
|
||||
});
|
||||
}
|
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
};
|
||||
|
||||
function spawn(callback) {
|
||||
log.info('Importer', 'Spawning importer process.');
|
||||
log.info('Importer', 'Spawning importer process');
|
||||
|
||||
knex.transaction(async tx => {
|
||||
await tx('imports').where('status', ImportStatus.PREP_RUNNING).update({status: ImportStatus.PREP_SCHEDULED});
|
||||
|
@ -36,14 +36,14 @@ function spawn(callback) {
|
|||
importerProcess.on('message', msg => {
|
||||
if (msg) {
|
||||
if (msg.type === 'importer-started') {
|
||||
log.info('Importer', 'Importer process started.');
|
||||
log.info('Importer', 'Importer process started');
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
importerProcess.on('close', (code, signal) => {
|
||||
log.info('Importer', 'Importer process exited with code %s signal %s.', code, signal);
|
||||
log.error('Importer', 'Importer process exited with code %s signal %s', code, signal);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ async function getOrCreateMailer(sendConfigurationId) {
|
|||
return transport.mailer;
|
||||
}
|
||||
|
||||
function invalidateMailer(sendConfiguration) {
|
||||
transports.delete(sendConfiguration.id);
|
||||
function invalidateMailer(sendConfigurationId) {
|
||||
transports.delete(sendConfigurationId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,7 +230,5 @@ async function _createTransport(sendConfiguration) {
|
|||
return transport;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getOrCreateMailer,
|
||||
invalidateMailer
|
||||
};
|
||||
module.exports.getOrCreateMailer = getOrCreateMailer;
|
||||
module.exports.invalidateMailer = invalidateMailer;
|
||||
|
|
58
lib/senders.js
Normal file
58
lib/senders.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
'use strict';
|
||||
|
||||
const fork = require('child_process').fork;
|
||||
const log = require('npmlog');
|
||||
const path = require('path');
|
||||
|
||||
let messageTid = 0;
|
||||
let senderProcess;
|
||||
|
||||
function spawn(callback) {
|
||||
log.info('Senders', 'Spawning master sender process');
|
||||
|
||||
senderProcess = fork(path.join(__dirname, '..', 'services', 'sender-master.js'), [], {
|
||||
cwd: path.join(__dirname, '..'),
|
||||
env: {NODE_ENV: process.env.NODE_ENV}
|
||||
});
|
||||
|
||||
senderProcess.on('message', msg => {
|
||||
if (msg) {
|
||||
if (msg.type === 'master-sender-started') {
|
||||
log.info('Senders', 'Master sender process started');
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
senderProcess.on('close', (code, signal) => {
|
||||
log.error('Senders', 'Master sender process exited with code %s signal %s', code, signal);
|
||||
});
|
||||
}
|
||||
|
||||
function scheduleCheck() {
|
||||
senderProcess.send({
|
||||
type: 'scheduleCheck',
|
||||
tid: messageTid
|
||||
});
|
||||
|
||||
messageTid++;
|
||||
}
|
||||
|
||||
function reloadConfig(sendConfigurationId) {
|
||||
senderProcess.send({
|
||||
type: 'reloadConfig',
|
||||
data: {
|
||||
sendConfigurationId
|
||||
},
|
||||
tid: messageTid
|
||||
});
|
||||
|
||||
messageTid++;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
spawn,
|
||||
scheduleCheck,
|
||||
reloadConfig
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue