MCPcopy Index your code
hub / github.com/simstudioai/sim / pollWebhook

Function pollWebhook

apps/sim/lib/webhooks/polling/rss.ts:82–158  ·  view source on GitHub ↗
(ctx: PollWebhookContext)

Source from the content-addressed store, hash-verified

80 label: 'RSS',
81
82 async pollWebhook(ctx: PollWebhookContext): Promise<'success' | 'failure'> {
83 const { webhookData, workflowData, requestId, logger } = ctx
84 const webhookId = webhookData.id
85
86 try {
87 const config = getProviderConfig<RssWebhookConfig>(webhookData.providerConfig)
88
89 if (!config?.feedUrl) {
90 logger.error(`[${requestId}] Missing feedUrl for webhook ${webhookId}`)
91 await markWebhookFailed(webhookId, logger)
92 return 'failure'
93 }
94
95 const now = new Date()
96 const {
97 feed,
98 items: newItems,
99 etag,
100 lastModified,
101 } = await fetchNewRssItems(config, requestId, logger)
102
103 if (!newItems.length) {
104 await updateRssState(webhookId, now.toISOString(), [], config, logger, etag, lastModified)
105 await markWebhookSuccess(webhookId, logger)
106 logger.info(`[${requestId}] No new items found for webhook ${webhookId}`)
107 return 'success'
108 }
109
110 logger.info(`[${requestId}] Found ${newItems.length} new items for webhook ${webhookId}`)
111
112 const { processedCount, failedCount } = await processRssItems(
113 newItems,
114 feed,
115 webhookData,
116 workflowData,
117 requestId,
118 logger
119 )
120
121 const newGuids = newItems
122 .map(
123 (item) =>
124 item.guid ||
125 item.link ||
126 (item.title && item.pubDate ? `${item.title}-${item.pubDate}` : '')
127 )
128 .filter((guid) => guid.length > 0)
129
130 await updateRssState(
131 webhookId,
132 now.toISOString(),
133 newGuids,
134 config,
135 logger,
136 etag,
137 lastModified
138 )
139

Callers

nothing calls this directly

Calls 9

getProviderConfigFunction · 0.90
markWebhookFailedFunction · 0.90
markWebhookSuccessFunction · 0.90
fetchNewRssItemsFunction · 0.85
updateRssStateFunction · 0.85
processRssItemsFunction · 0.85
errorMethod · 0.80
infoMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected