webiny / webiny-js

Open-source serverless enterprise CMS. Includes a headless CMS, page builder, form builder, and file manager. Easy to customize and expand. Deploys to AWS.
https://www.webiny.com
Other
7.29k stars 601 forks source link

feat(api-headless-cms): empty HCMS trash bin via cron job #4085

Closed leopuleo closed 4 months ago

leopuleo commented 4 months ago

Changes

With this PR, we handle the deletion of HCMS entries found in the trash bin that were moved there before a specific date.

This is the overall process description:

  1. Every day at 3:00 am UTC, an EventBridge event triggers our main api-graphql lambda.
  2. a new hcmsEntriesEmptyTrashBins background task is triggered for each tenant registered.

hcmsEntriesEmptyTrashBins

The hcmsEntriesEmptyTrashBins task triggers a hcmsEntriesEmptyTrashBinByModel background task for each public model registered.

hcmsEntriesEmptyTrashBinByModel

This background task receives as input:

The task lists the entries to delete according to the query received and triggers hcmsEntriesDeleteTrashBinEntries tasks.

hcmsEntriesDeleteTrashBinEntries

This background task receives as input:

Related PR

https://github.com/webiny/webiny-upgrades/pull/29

How Has This Been Tested?

Jest + manually

Documentation

We must document how to set the trash bin retention period using the env variable (WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS).