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

Function filterChanges

apps/sim/lib/webhooks/polling/google-drive.ts:327–359  ·  view source on GitHub ↗
(
  changes: DriveChangeEntry[],
  config: GoogleDriveWebhookConfig
)

Source from the content-addressed store, hash-verified

325}
326
327function filterChanges(
328 changes: DriveChangeEntry[],
329 config: GoogleDriveWebhookConfig
330): DriveChangeEntry[] {
331 return changes.filter((change) => {
332 if (change.removed) return true
333
334 const file = change.file
335 if (!file) return false
336
337 if (file.trashed) return false
338
339 // Canonical key `folderId` first; `manualFolderId` is a transitional basic-first fallback.
340 const folderId = readCanonicalTriggerValue(config.folderId, config.manualFolderId)
341 if (folderId) {
342 if (!file.parents || !file.parents.includes(folderId)) {
343 return false
344 }
345 }
346
347 if (config.mimeTypeFilter) {
348 if (config.mimeTypeFilter.endsWith('/')) {
349 if (!file.mimeType.startsWith(config.mimeTypeFilter)) {
350 return false
351 }
352 } else if (file.mimeType !== config.mimeTypeFilter) {
353 return false
354 }
355 }
356
357 return true
358 })
359}
360
361async function processChanges(
362 changes: DriveChangeEntry[],

Callers 1

pollWebhookFunction · 0.85

Calls 1

Tested by

no test coverage detected