Browse Source

Fix news polling regression

ghorsington 5 years ago
parent
commit
55d274f036

+ 7 - 2
src/commands/aggregators/com3d2_updates.ts

@@ -1,4 +1,4 @@
-import html, { HTMLElement } from "node-html-parser";
+import * as html from "node-html-parser";
 import request from "request-promise-native";
 import { Response } from "request";
 import { IAggregator, INewsItem } from "./aggregator";
@@ -24,6 +24,11 @@ async function aggregate() {
         where: { feedName: FEED_NAME },
         order: { newsId: "DESC" }
     });
+
+    if(!lastPost)
+        lastPost = repo.create({
+            newsId: 0
+        });
     
     try {
         let mainPageRes = await request(updatePage, {resolveWithFullResponse: true}) as Response;
@@ -37,7 +42,7 @@ async function aggregate() {
                 style: false
         });
 
-        if(!(rootNode instanceof HTMLElement))
+        if(!(rootNode instanceof html.HTMLElement))
             return;
 
         let readme = rootNode.querySelector("div.readme");

+ 8 - 3
src/commands/aggregators/com3d2_world.ts

@@ -1,4 +1,4 @@
-import html, { HTMLElement } from "node-html-parser";
+import * as html from "node-html-parser";
 import request from "request-promise-native";
 import { Response } from "request";
 import { INewsItem, IAggregator } from "./aggregator";
@@ -17,6 +17,11 @@ async function aggregate() {
         order: { newsId: "DESC" }
     });
 
+    if(!lastPost)
+        lastPost = repo.create({
+            newsId: 0
+        });
+
     try {
         let mainPageRes = await request(kissDiaryRoot, {resolveWithFullResponse: true}) as Response;
         
@@ -29,7 +34,7 @@ async function aggregate() {
                 style: false
         });
 
-        if(!(rootNode instanceof HTMLElement))
+        if(!(rootNode instanceof html.HTMLElement))
             return;
 
         let diaryEntries = rootNode.querySelectorAll("div.frame a");
@@ -64,7 +69,7 @@ async function aggregate() {
                 style: false
             });
 
-            if(!(node instanceof HTMLElement))
+            if(!(node instanceof html.HTMLElement))
                 continue;
 
             let title = node.querySelector("div.frame div.notice_title th");

+ 9 - 4
src/commands/aggregators/kiss_diary.ts

@@ -1,4 +1,4 @@
-import html, { HTMLElement } from "node-html-parser";
+import * as html from "node-html-parser";
 import request from "request-promise-native";
 import { Response } from "request";
 import { INewsItem, IAggregator } from "./aggregator";
@@ -17,6 +17,11 @@ async function aggregate() {
         where: { feedName: FEED_NAME },
         order: { newsId: "DESC" }
     });
+
+    if(!lastPost)
+        lastPost = repo.create({
+            newsId: 0
+        });
     
     try {
         let mainPageRes = await request(`${kissDiaryRoot}/diary.php`, {resolveWithFullResponse: true}) as Response;
@@ -30,7 +35,7 @@ async function aggregate() {
                 style: false
         });
 
-        if(!(rootNode instanceof HTMLElement))
+        if(!(rootNode instanceof html.HTMLElement))
             return;
 
         let diaryEntries = rootNode.querySelectorAll("div.blog_frame_middle ul.disc li a");
@@ -66,7 +71,7 @@ async function aggregate() {
                 style: false
             });
 
-            if(!(node instanceof HTMLElement))
+            if(!(node instanceof html.HTMLElement))
                 continue;
 
             let title = node.querySelector("table.blog_frame_top tr td a");
@@ -74,7 +79,7 @@ async function aggregate() {
             let bottomFrame = contents.querySelector("div.blog_data");
             if(bottomFrame) {
                 let child = contents.childNodes[0];
-                if(child instanceof HTMLElement)
+                if(child instanceof html.HTMLElement)
                     child.removeChild(bottomFrame);
             }