( changes: DriveChangeEntry[], config: GoogleDriveWebhookConfig )
| 325 | } |
| 326 | |
| 327 | function 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 | |
| 361 | async function processChanges( |
| 362 | changes: DriveChangeEntry[], |
no test coverage detected