After we get serviceMessages, save internet to db.

This commit is contained in:
2020-06-03 00:19:30 +02:00
committed by KevinMidboe
parent 9cc4218bf2
commit cce9c0d6ea

View File

@@ -6,13 +6,17 @@ const config = require('../config')
const Mail = require( './mail.js'); const Mail = require( './mail.js');
const mail = new Mail(); const mail = new Mail();
const { commitServiceEventToDatabase, getAllEvents } = require('./db.js');
let browser = undefined; let browser = undefined;
if (config.debug == false) if (config.debug == false)
console.log = () => {} console.log = () => {}
const pdfFilename = config['pdfFilename'] || 'telenor-downtime.pdf';
const savePageToPDF = page => { const savePageToPDF = page => {
const pdfOptions = { const pdfOptions = {
path: `telenor-downtime.pdf`, path: pdfFilename,
format: "A4", format: "A4",
printBackground: true, printBackground: true,
displayHeaderFooter: true, displayHeaderFooter: true,
@@ -120,6 +124,7 @@ function run() {
.then(page => dismissCookiePrompt(page)) .then(page => dismissCookiePrompt(page))
.then(page => savePageToPDF(page)) .then(page => savePageToPDF(page))
.then(page => getServiceMessages(page)) .then(page => getServiceMessages(page))
.then(serviceMessages => commitServiceEventToDatabase(serviceMessages, pdfFilename))
.then(serviceMessages => notifyIfDown(serviceMessages)) .then(serviceMessages => notifyIfDown(serviceMessages))
.then(closeBrowser) .then(closeBrowser)
} }