Repository: tweedegolf/mailcrab (language: rust)

Issue:
logging of expire deletion
The events of incoming email and API delete email are being logged.

Deletion of email due expire, age > `MAILCRAB_RETENTION_PERIOD`, is **not** logged.


 


Discussion / hints:
I have tried to find where to insert the missing `event!()`, but failed. Would like to get clues where to look closer.    :wink:
Hi Geert. In the storage module https://github.com/tweedegolf/mailcrab/blob/main/backend/src/storage.rs#L45 all messages are filtered with using `retain`. You could give the closure a body and add the log statement there. Any PR is welcome :-) 

Fix patch:
diff --git a/backend/src/storage.rs b/backend/src/storage.rs
index 9022ea8..e48b050 100644
--- a/backend/src/storage.rs
+++ b/backend/src/storage.rs
@@ -42,7 +42,16 @@ pub(crate) async fn storage(
                             .duration_since(SystemTime::UNIX_EPOCH)?
                             .as_secs() as i64;
 
-                        storage.retain(|_, mail_message| mail_message.time > remove_before);
+                        storage.retain(|_, mail_message| {
+                            if mail_message.time > remove_before {
+                                true
+                            } else {
+                                info!("Removing old message {} from {}", mail_message.id, mail_message.envelope_from);
+
+                                false
+                            }
+
+                        });
                     }
                 }
             },


Test patch: