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

Function checkSubscription

apps/sim/lib/workspace-events/no-activity.ts:208–236  ·  view source on GitHub ↗

* Checks a single no_activity subscription's watched workflows and fires * events for the inactive ones, accumulating counts into `result`. The * watched-workflow scan is keyset-paginated, so coverage is complete even in * workspaces with more workflows than one page.

(
  subscription: SimSubscription,
  result: NoActivityPollResult
)

Source from the content-addressed store, hash-verified

206 * workspaces with more workflows than one page.
207 */
208async function checkSubscription(
209 subscription: SimSubscription,
210 result: NoActivityPollResult
211): Promise<void> {
212 const config = parseSubscriptionConfig(subscription.webhook.providerConfig)
213 if (!config || config.eventType !== 'no_activity') return
214
215 const workspaceId = subscription.workflow.workspaceId
216 if (!workspaceId) return
217
218 let cursor: string | null = null
219 while (true) {
220 const page = await fetchWatchedWorkflowPage(
221 workspaceId,
222 subscription.webhook.workflowId,
223 config,
224 cursor
225 )
226 if (page.length === 0) break
227
228 cursor = page[page.length - 1].id
229
230 for (const sourceWorkflow of page) {
231 await checkWatchedWorkflow(subscription, config, sourceWorkflow, result)
232 }
233
234 if (page.length < NO_ACTIVITY_WORKFLOW_PAGE_SIZE) break
235 }
236}
237
238/**
239 * Checks every no_activity subscription and fires side-effect workflows for

Callers 1

pollNoActivityEventsFunction · 0.85

Calls 3

parseSubscriptionConfigFunction · 0.90
fetchWatchedWorkflowPageFunction · 0.85
checkWatchedWorkflowFunction · 0.85

Tested by

no test coverage detected