- Issue created by @endless_wander
- πΊπΈUnited States laboratory.mike
Currently I have this in a cron job:
$now = new DrupalDateTime('-90 days'); $delete = \Drupal::database()->delete('mail_safety_dashboard'); $delete->condition('sent', $now->getTimestamp(), '<'); $delete->execute();
We could set this up in a container with dependency injection, and add a config to set the retention time.
- π§πͺBelgium flyke
Thank you laboratory.mike, your solution is a perfect stop gap until we get an actual settings page and this functionality incorporated into the module itself.
/** * Implements hook_mail(). */ function mymodule_helper_cron() { // Delete old mail logs. $now = new DrupalDateTime('-90 days'); $delete = \Drupal::database()->delete('mail_safety_dashboard'); $delete->condition('sent', $now->getTimestamp(), '<'); $delete->execute(); }
- πΊπΈUnited States drupgirl
+1 for this essential function being incorporated.
- π΅πΉPortugal nsalves
Here's a patch that adds the functionality. It adds a cron job that reads an offset value configured in the settings page of the module. If no value is configured the cron does nothing and everything remains as it is
- π³π±Netherlands sjerdo Haarlem
@nsalves Thanks for providing a patch. Could you create a MR for this change?
There are some code style issues with this patch (in file `mail_safety.module`) which needs attention before we can merge this into the main branch: indent and function doc-block refers to the incorrect hook.
- First commit to issue fork.
- π΅πΉPortugal nsalves
Hello sjerdo, thanks for the feedback and apologies for the oversight. Merge request opened.
Thanks