[Dovecot] Request for help with new plugin
Hi there,
I was having lots of trouble with the normal expire plugin so I
decided to try and come up with a plugin that handles the trash
directory in the same way as Courier (when the user logs out it should
clean messages from the trash that have been there for more than X
days.) I used the expire and trash plugins as a guide but there are
probably a number of things done wrong here and I have plenty of
questions.
To use this you'd need to run autoreconf for the autotools scripts,
compile, make, make install, then add "autoexpire" to the imap/pop3
mail_plugins lists and "autoexpire = Trash 7" to the plugin section.
Is there any documentation of how the hook system and virtual
mailboxes work outside of the source code?I'd like the Trash cleanup to occur at logout, but the closest I
could find was mailbox close. This makes the behavior a little
quirky. It seems like Dovecot closes the mailbox each time it
performs an operation on it, so when the client gets a list of mail in
the box it does a close and the oldest items in the returned list will
actually be expunged.Is SAVE_DATE the correct field to be looking for here? I want the
expiration to be based on the amount of time the letter has spent in
the trash folder.For searching through the Trash folder, SEARCH_BEFORE doesn't seem
to match up with SAVE_DATE. Is there some other way to limit the
search results to the dates that will fall before a certain SAVE_DATE
value?
J.D.
On Thu, 2008-10-09 at 10:26 -0500, John Lightsey wrote:
- Is there any documentation of how the hook system and virtual
mailboxes work outside of the source code?
Unfortunately I haven't had time to write docs.
- I'd like the Trash cleanup to occur at logout, but the closest I
could find was mailbox close. This makes the behavior a little
quirky. It seems like Dovecot closes the mailbox each time it
performs an operation on it, so when the client gets a list of mail in
the box it does a close and the oldest items in the returned list will
actually be expunged.
You could hook into mail_storage.destroy() (the same way you're hooking into mailbox_open).
- Is SAVE_DATE the correct field to be looking for here? I want the
expiration to be based on the amount of time the letter has spent in
the trash folder.
Yes.
- For searching through the Trash folder, SEARCH_BEFORE doesn't seem
to match up with SAVE_DATE. Is there some other way to limit the
search results to the dates that will fall before a certain SAVE_DATE
value?
No, but it doesn't really matter. The oldest mails are always at the beginning of the mailbox. So just search for all mails and stop searching when you encounter a mail with too high save_date.
About the code:
rc = gettimeofday( &now, NULL);
Just use ioloop_time (from ioloop.h). It's updated all the time automatically and it's close enough to the current time always.
Other than that (and the SEARCH_BEFORE) it looked good.
On 10/18/2008, Timo Sirainen (tss@iki.fi) wrote:
- Is SAVE_DATE the correct field to be looking for here? I want the
expiration to be based on the amount of time the letter has spent in
the trash folder.
Yes.
I'm not a prgrammer, so would have zero success answering this myself from looking at the code, but just want to clarify...
In this case, SAVE_DATE mean the dat/time the message was originally delivered? Or does it mean the date/tim the message was simply moved to the TRASH?
--
Best regards,
Charles
On Sat, 2008-10-18 at 11:49 -0400, Charles Marcus wrote:
On 10/18/2008, Timo Sirainen (tss@iki.fi) wrote:
- Is SAVE_DATE the correct field to be looking for here? I want the
expiration to be based on the amount of time the letter has spent in
the trash folder.Yes.
I'm not a prgrammer, so would have zero success answering this myself from looking at the code, but just want to clarify...
In this case, SAVE_DATE mean the dat/time the message was originally delivered? Or does it mean the date/tim the message was simply moved to the TRASH?
It's the date/time of when the message was saved/copied to that particular mailbox.
Since Maildir doesn't itself support save_date, Dovecot uses file's ctime as the save_date. So it may change if the ctime changes (e.g. message flags change). But the save_date is also added to Dovecot's cache file, so once it's looked up it shouldn't change (unless cache file gets deleted or something). Anyway I don't think this should cause any real problems.
On 10/18/2008, Timo Sirainen (tss@iki.fi) wrote:
In this case, SAVE_DATE mean the dat/time the message was originally delivered? Or does it mean the date/tim the message was simply moved to the TRASH?
It's the date/time of when the message was saved/copied to that particular mailbox.
Good to know, thanks...
--
Best regards,
Charles
participants (3)
-
Charles Marcus
-
John Lightsey
-
Timo Sirainen