feat(rss): add new items in feed trigger
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "~4.16.1",
|
||||
"express-graphql": "^0.12.0",
|
||||
"fast-xml-parser": "^4.0.11",
|
||||
"flickr-sdk": "3.10.0",
|
||||
"googleapis": "89.0.0",
|
||||
"graphql-middleware": "^6.1.15",
|
||||
@@ -134,4 +135,4 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
packages/backend/src/apps/rss/assets/favicon.svg
Normal file
6
packages/backend/src/apps/rss/assets/favicon.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
aria-label="RSS" role="img"
|
||||
viewBox="0 0 512 512"><rect
|
||||
width="512" height="512"
|
||||
rx="15%"
|
||||
fill="#f80"/><circle cx="145" cy="367" r="35" fill="#fff"/><path fill="none" stroke="#fff" stroke-width="60" d="M109 241c89 0 162 73 162 162m114 0c0-152-124-276-276-276"/></svg>
|
After Width: | Height: | Size: 307 B |
0
packages/backend/src/apps/rss/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/rss/index.d.ts
vendored
Normal file
13
packages/backend/src/apps/rss/index.ts
Normal file
13
packages/backend/src/apps/rss/index.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
|
||||
export default defineApp({
|
||||
name: 'RSS',
|
||||
key: 'rss',
|
||||
iconUrl: '{BASE_URL}/apps/rss/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/connections/rss',
|
||||
supportsConnections: false,
|
||||
baseUrl: '',
|
||||
apiBaseUrl: '',
|
||||
primaryColor: 'ff8800',
|
||||
beforeRequest: [],
|
||||
});
|
@@ -0,0 +1,33 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import newItemsInFeed from './new-items-in-feed';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New items in feed',
|
||||
key: 'newItemsInFeed',
|
||||
description: 'Triggers on new RSS feed items.',
|
||||
pollInterval: 15,
|
||||
substeps: [
|
||||
{
|
||||
key: 'chooseTrigger',
|
||||
name: 'Set up trigger',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Feed URL',
|
||||
key: 'feedUrl',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Paste your publicly accessible RSS URL here.',
|
||||
variables: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'testStep',
|
||||
name: 'Test trigger',
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
await newItemsInFeed($);
|
||||
},
|
||||
});
|
@@ -0,0 +1,24 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { XMLParser } from 'fast-xml-parser';[]
|
||||
|
||||
const newItemsInFeed = async ($: IGlobalVariable) => {
|
||||
const { data } = await $.http.get($.step.parameters.feedUrl as string);
|
||||
const parser = new XMLParser();
|
||||
const parsedData = parser.parse(data);
|
||||
|
||||
for (const item of parsedData.rss.channel.item) {
|
||||
if ($.flow.isAlreadyProcessed(item.guid))
|
||||
return;
|
||||
|
||||
const dataItem = {
|
||||
raw: item,
|
||||
meta: {
|
||||
internalId: item.guid
|
||||
}
|
||||
}
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
}
|
||||
};
|
||||
|
||||
export default newItemsInFeed;
|
@@ -155,13 +155,14 @@ enum AvailableAppsEnumType {
|
||||
github
|
||||
gitlab
|
||||
postgresql
|
||||
rss
|
||||
scheduler
|
||||
slack
|
||||
smtp
|
||||
twilio
|
||||
twitch
|
||||
twitter
|
||||
typeform
|
||||
slack
|
||||
scheduler
|
||||
}
|
||||
|
||||
type Connection {
|
||||
|
Reference in New Issue
Block a user