diff --git a/package-lock.json b/package-lock.json index b64e8c5..da1fec5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "smf", - "version": "4.00.0", + "version": "4.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1b676aa..3751e22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smf", - "version": "4.00.0", + "version": "4.1.0", "description": "Harvest recent postings from SMF", "dependencies": { "axios": "^0.21.1", diff --git a/smf.js b/smf.js index 2b3a9bc..87cc4db 100644 --- a/smf.js +++ b/smf.js @@ -18,11 +18,9 @@ Copyright 2011-2021 James Tittsler const axios = require('axios').default; const process = require("process"); -const url = require("url"); const cheerio = require("cheerio"); const nodemailer = require("nodemailer"); const fs = require("fs"); -const os = require("os"); const ini = require("ini"); var config = ini.parse(fs.readFileSync("./smf.rc", "utf-8")); let smtpConfig = { @@ -70,7 +68,6 @@ function getHighWaterMark() { process.exit(1); } - console.log(`high water mark ${highwater}`); if (isNaN(highwater) || highwater == 0) { console.error('high water mark not set'); log.error('high water mark not set'); @@ -106,94 +103,30 @@ function unHTMLEntities(a) { return a; }; -async function processPage(item, page) { - let url = item.link; - let msgid = url.replace(/.*#msg/, ''); - let $ = cheerio.load(page); - // look through all the div.post_wrapper for one that contains - // a subject for the desired message number - let $h5 = $(`#subject_${msgid}`); - let $el = $h5.closest(".post_wrapper"); - let from = $el - .find('div.poster a[title^="View the profile of"]') - .eq(0) - .text(); - let $post = $el.find("div.post").eq(0); - $("div.quote", $post).attr( - "style", - "color: #000; background-color: #d7daec; margin: 1px; padding: 6px; font-size: 1em; line-height: 1.5em; font-style: italic; font-family: Georgia, Times, serif;" - ); - $("div.quoteheader,div.codeheader", $post).attr( - "style", - "color: #000; text-decoration: none; font-style: normal; font-weight: bold; font-size: 1em; line-height: 1.2em; padding-bottom: 4px;" - ); - $(".meaction", $post).attr("style", "color: red;"); - $("embed", $post).each(function () { - let src = decodeURIComponent($(this).attr("src")); - log.debug(` embed: ${src}`); - return $(this).replaceWith(`
`); - }); - let $attachments = $el.find("div.attachments"); - if ($attachments) { - $attachments.attr("style", "font-size: 0.8em;"); - $("a", $attachments) - .prop("onclick", null); - $post.append($attachments); - } - let post = $post.html(); - let d = new Date(item.pubDate); - let isodate = d.toISOString(); - let originalLink = item.link; - if (config.smf.protocol.startsWith('https')) { - originalLink = originalLink.replace('http:', 'https:'); - } - log.debug(`From: ${from}`); - log.debug(`Subject: [${item.category}] ${unHTMLEntities(item.title)}`); - log.debug(`Date: ${isodate} Lastdate: ${lastdate.toISOString()}`); - mailer.sendMail( - { - from: `"${from}" ${config.email.sender}`, - to: config.email.to, - subject: `[${item.category}] ${unHTMLEntities(item.title.trim())}`, - html: `` - }, - function (error) { - if (error) { - log.debug(`>>failed to send mail ${msgid}`); - log.debug(error); - process.exit(1); - } - }); - log.debug(`>>sent ${msgid} (${isodate}) for ${item.category}`); - await config.db.run("UPDATE feeds SET last=(?) WHERE category=(?)", - isodate, item.category); -} - /** * @returns {Promise