Skip to content

Conversation

@alfetopito
Copy link
Contributor

@alfetopito alfetopito commented Mar 7, 2025

Summary

  • Add a cronjob to clean notifications whose notification-template dueDate is paste > 1 week
  • Add a lifecycle hook to delete notifications when a notification-template is removed

Testing

  1. Start the service locally
  2. Add a few notification-templates, where:
    1. at least one is due > 1 week
    2. one is due < 1 week
    3. one is not due
    4. one doesn't have a dueDate
  3. Add a notification for each notification-template
  4. Add a notification without a notification-template
  5. Change the conjob to run every minute (*/1 * * * * ) and start the dev server
  • After ~1 min, the notification due > 1 week AND the one without notification-template should have been removed
  1. Manually remove any notification-template using the admin panel
  • The associated notification should be removed as well

@alfetopito alfetopito self-assigned this Mar 7, 2025
@alfetopito alfetopito requested a review from a team March 7, 2025 17:34
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated files after a yarn build.

Changes not related to this PR

Copy link

@cowdan cowdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of minor comments, otherwise lgtm

Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this is a neat solution!

I didn't know there was a cron in strapi, I thought you were adding it in GH. This is way better, and more secure so we don't need to give GH actions deletion access/

Thanks for fixing this

@alfetopito alfetopito merged commit 5d16c29 into main Mar 11, 2025
3 checks passed
@alfetopito alfetopito deleted the feat/clean-notifications branch March 13, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants