diff --git a/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts b/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts index de99207da8..585abb52bb 100644 --- a/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts +++ b/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts @@ -54,6 +54,14 @@ export class RssFeedRead implements INodeType { placeholder: 'Add option', default: {}, options: [ + { + displayName: 'Custom Fields', + name: 'customFields', + type: 'string', + default: '', + description: + 'A comma-separated list of custom fields to include in the output. For example, "author, contentSnippet".', + }, { displayName: 'Ignore SSL Issues (Insecure)', name: 'ignoreSSL', @@ -111,6 +119,13 @@ export class RssFeedRead implements INodeType { }; } + if (options.customFields) { + const customFields = options.customFields as string; + parserOptions.customFields = { + item: customFields.split(',').map((field) => field.trim()), + }; + } + const parser = new Parser(parserOptions); let feed: Parser.Output; @@ -132,13 +147,12 @@ export class RssFeedRead implements INodeType { }); } - // For now we just take the items and ignore everything else if (feed.items) { const feedItems = (feed.items as IDataObject[]).map((item) => ({ json: item, })) as INodeExecutionData[]; - const itemData = fallbackPairedItems || [{ item: i }]; + const itemData = fallbackPairedItems ?? [{ item: i }]; const executionData = this.helpers.constructExecutionMetaData(feedItems, { itemData, @@ -150,7 +164,7 @@ export class RssFeedRead implements INodeType { if (this.continueOnFail()) { returnData.push({ json: { error: error.message }, - pairedItem: fallbackPairedItems || [{ item: i }], + pairedItem: fallbackPairedItems ?? [{ item: i }], }); continue; } diff --git a/packages/nodes-base/nodes/RssFeedRead/test/node/RssFeedRead.test.ts b/packages/nodes-base/nodes/RssFeedRead/test/node/RssFeedRead.test.ts index c2ea4f477a..5f04353706 100644 --- a/packages/nodes-base/nodes/RssFeedRead/test/node/RssFeedRead.test.ts +++ b/packages/nodes-base/nodes/RssFeedRead/test/node/RssFeedRead.test.ts @@ -2,7 +2,7 @@ import { NodeTestHarness } from '@nodes-testing/node-test-harness'; import nock from 'nock'; // eslint-disable-next-line n8n-local-rules/no-unneeded-backticks -const feed = `<![CDATA[Lorem ipsum feed for an interval of 1 minutes with 3 item(s)]]>http://example.com/RSS for NodeThu, 09 Feb 2023 13:40:32 GMTThu, 09 Feb 2023 13:40:00 GMT1<![CDATA[Lorem ipsum 2023-02-09T13:40:00Z]]>http://example.com/test/1675950000http://example.com/test/1675950000Thu, 09 Feb 2023 13:40:00 GMT<![CDATA[Lorem ipsum 2023-02-09T13:39:00Z]]>http://example.com/test/1675949940http://example.com/test/1675949940Thu, 09 Feb 2023 13:39:00 GMT<![CDATA[Lorem ipsum 2023-02-09T13:38:00Z]]>http://example.com/test/1675949880http://example.com/test/1675949880Thu, 09 Feb 2023 13:38:00 GMT`; +const feed = `<![CDATA[Lorem ipsum feed for an interval of 1 minutes with 3 item(s)]]>http://example.com/RSS for NodeThu, 09 Feb 2023 13:40:32 GMTThu, 09 Feb 2023 13:40:00 GMT1<![CDATA[Lorem ipsum 2023-02-09T13:40:00Z]]>http://example.com/test/1675950000http://example.com/test/1675950000Thu, 09 Feb 2023 13:40:00 GMTcustom<![CDATA[Lorem ipsum 2023-02-09T13:39:00Z]]>http://example.com/test/1675949940http://example.com/test/1675949940Thu, 09 Feb 2023 13:39:00 GMTcustom<![CDATA[Lorem ipsum 2023-02-09T13:38:00Z]]>http://example.com/test/1675949880http://example.com/test/1675949880Thu, 09 Feb 2023 13:38:00 GMTcustom`; describe('Test RSS Feed Trigger Node', () => { beforeAll(() => { @@ -10,6 +10,7 @@ describe('Test RSS Feed Trigger Node', () => { nock('https://fake-rss-feed.com') .get('/feed') .reply(200, feed, { 'Content-Type': 'application/xml; charset=utf-8' }); + nock('https://custom-rss-feed.com').get('/feed').reply(200, feed); }); new NodeTestHarness().setupTests(); diff --git a/packages/nodes-base/nodes/RssFeedRead/test/node/workflow.rss.json b/packages/nodes-base/nodes/RssFeedRead/test/node/workflow.rss.json index 49dbf5a319..67d4edbcc9 100644 --- a/packages/nodes-base/nodes/RssFeedRead/test/node/workflow.rss.json +++ b/packages/nodes-base/nodes/RssFeedRead/test/node/workflow.rss.json @@ -3,22 +3,22 @@ "nodes": [ { "parameters": {}, - "id": "4d0527e8-1906-4c09-bbd7-fa3d88f13195", + "id": "448372da-bc2d-4952-8d16-4b3384cd3c3d", "name": "When clicking \"Execute Workflow\"", "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, - "position": [-200, -220] + "position": [-112, -176] }, { "parameters": { "url": "https://lorem-rss.herokuapp.com/feed?length=3", "options": {} }, - "id": "bb54b66c-2c40-4ea2-a1ae-5fef2186e4bd", + "id": "13b7f0a0-db25-4ff3-9e61-4748f6910860", "name": "RSS Read", "type": "n8n-nodes-base.rssFeedRead", "typeVersion": 1, - "position": [0, -220] + "position": [96, -176] }, { "parameters": { @@ -27,9 +27,22 @@ }, "type": "n8n-nodes-base.rssFeedRead", "typeVersion": 1.2, - "position": [0, -40], - "id": "9b67fdd9-23de-40ae-b477-cb121a4ed5c8", + "position": [96, 16], + "id": "ec469874-0ca2-457e-9204-77417d08ef90", "name": "RSS Read1" + }, + { + "parameters": { + "url": "https://custom-rss-feed.com/feed", + "options": { + "customFields": "custom" + } + }, + "type": "n8n-nodes-base.rssFeedRead", + "typeVersion": 1.2, + "position": [96, 176], + "id": "6b9593c7-22e0-4ed6-a2ca-bd48aecdfc59", + "name": "RSS With Custom" } ], "pinData": { @@ -114,6 +127,50 @@ "isoDate": "2023-02-09T13:38:00.000Z" } } + ], + "RSS With Custom": [ + { + "json": { + "creator": "John Smith", + "title": "Lorem ipsum 2023-02-09T13:40:00Z", + "link": "http://example.com/test/1675950000", + "pubDate": "Thu, 09 Feb 2023 13:40:00 GMT", + "dc:creator": "John Smith", + "content": "Fugiat excepteur exercitation tempor ut aute sunt pariatur veniam pariatur dolor.", + "contentSnippet": "Fugiat excepteur exercitation tempor ut aute sunt pariatur veniam pariatur dolor.", + "guid": "http://example.com/test/1675950000", + "isoDate": "2023-02-09T13:40:00.000Z", + "custom": "custom" + } + }, + { + "json": { + "creator": "John Smith", + "title": "Lorem ipsum 2023-02-09T13:39:00Z", + "link": "http://example.com/test/1675949940", + "pubDate": "Thu, 09 Feb 2023 13:39:00 GMT", + "dc:creator": "John Smith", + "content": "Laboris quis nulla tempor eu ullamco est esse qui aute commodo aliqua occaecat.", + "contentSnippet": "Laboris quis nulla tempor eu ullamco est esse qui aute commodo aliqua occaecat.", + "guid": "http://example.com/test/1675949940", + "isoDate": "2023-02-09T13:39:00.000Z", + "custom": "custom" + } + }, + { + "json": { + "creator": "John Smith", + "title": "Lorem ipsum 2023-02-09T13:38:00Z", + "link": "http://example.com/test/1675949880", + "pubDate": "Thu, 09 Feb 2023 13:38:00 GMT", + "dc:creator": "John Smith", + "content": "Irure labore dolor dolore sint aliquip eu anim aute anim et nulla adipisicing nostrud.", + "contentSnippet": "Irure labore dolor dolore sint aliquip eu anim aute anim et nulla adipisicing nostrud.", + "guid": "http://example.com/test/1675949880", + "isoDate": "2023-02-09T13:38:00.000Z", + "custom": "custom" + } + } ] }, "connections": { @@ -129,6 +186,11 @@ "node": "RSS Read1", "type": "main", "index": 0 + }, + { + "node": "RSS With Custom", + "type": "main", + "index": 0 } ] ] @@ -138,10 +200,10 @@ "settings": { "executionOrder": "v1" }, - "versionId": "9bb18c59-4606-4889-a2b0-40284952c604", + "versionId": "11023520-13ee-48bf-80b4-81821316ec5f", "meta": { "instanceId": "0fa937d34dcabeff4bd6480d3b42cc95edf3bc20e6810819086ef1ce2623639d" }, - "id": "wWDle8xVd0Elxoa0", + "id": "hKwPhUVv6w8I1s7M", "tags": [] }