From 782b1edd53a12524f1c2520d1de2c04175f9f6cd Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Sat, 20 Mar 2021 13:18:24 +0100 Subject: [PATCH] add the option ignoreReplies - now for real --- package.json | 2 +- src/mastodon/feed-parser.js | 2 +- test/__mocks__/masto-feed-with-replies.xml | 62 ++++++++++++++++++++++ test/mastodon/feed-parser.test.js | 2 +- 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 916e8f1..f4be790 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jam-my-stack", - "version": "1.0.14", + "version": "1.0.15", "repository": { "url": "https://github.com/wgroeneveld/jam-my-stack", "type": "git" diff --git a/src/mastodon/feed-parser.js b/src/mastodon/feed-parser.js index 2960ee2..9ab94de 100644 --- a/src/mastodon/feed-parser.js +++ b/src/mastodon/feed-parser.js @@ -101,7 +101,7 @@ async function parseMastoFeed(options) { day } }) - .filter(itm => ignoreReplies ? itm.context .length > 0 : true) + .filter(itm => ignoreReplies ? !itm.context : true) .filter(itm => !notes.includes(`${itm.year}/${itm.month}/${itm.hash}`)) .forEach(itm => convertAtomItemToMd(itm, notesdir)) } diff --git a/test/__mocks__/masto-feed-with-replies.xml b/test/__mocks__/masto-feed-with-replies.xml index 6bb7284..401a9a9 100644 --- a/test/__mocks__/masto-feed-with-replies.xml +++ b/test/__mocks__/masto-feed-with-replies.xml @@ -33,6 +33,68 @@ + + + http://activitystrea.ms/schema/1.0/note + http://activitystrea.ms/schema/1.0/post + https://chat.brainbaking.com/objects/b5b67e88-eda8-45dd-ab8f-54443b62e250 + @houkimenator Aren&#39;t you forgetting that it is (mostly) the state that makes sure universit... + <span class="h-card"><a class="u-url mention" data-user="A5OhJ18LyRGm37qKgK" href="https://mastodon.technology/@houkimenator" rel="ugc">@<span>houkimenator</span></a></span> <br><br>Aren&#39;t you forgetting that it is (mostly) the state that makes sure universities receive funding to be able to do the research in the first place? Curious to see your view on that &#39;free&#39; ecosystem in the future. I hope you aren&#39;t insinuating to privatize that fund flow. <br><br><span class="h-card"><a class="u-url mention" data-user="A58Lcc2JgjJWTxbCxU" href="https://mastodon.social/@fribbledom" rel="ugc">@<span>fribbledom</span></a></span> + 2021-03-20T11:12:08.955177Z + 2021-03-20T11:12:08.955177Z + + tag:mastodon.social,2021-03-20:objectId=227433498:objectType=Conversation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://activitystrea.ms/schema/1.0/note http://activitystrea.ms/schema/1.0/post diff --git a/test/mastodon/feed-parser.test.js b/test/mastodon/feed-parser.test.js index 6902504..5253e7d 100644 --- a/test/mastodon/feed-parser.test.js +++ b/test/mastodon/feed-parser.test.js @@ -37,7 +37,7 @@ describe("mastodon feed parser tests", () => { }) dir = await fsp.readdir(`${dumpdir}/2021/03`, { withFileTypes: true }) - expect(dir.length).toBe(2) + expect(dir.length).toBe(3) }) })