[imapfilter-devel] imapfilter 2.2 broke this LUA function, help?
Rob Austein
sra at hactrn.net
Fri Jun 4 19:48:31 EEST 2010
The following function worked until I upgraded to imapfilter 2.2.
I understand that the underlying problem is that the search results
table format has changed significantly, but it's far from obvious how
to achieve anything like the same result with 2.2. Which is a pity,
as the ability to do this kind of thing from a nightly cron job has
always been one of the best things about imapfilter. Any suggestions?
-- Archive old messages. This is (sort of) a recreation of something
-- that existed in the original 0.x version of imapfilter, rewritten
-- in LUA. Move old unflagged seen messages to archive mailboxes
-- named using the internal date of the message. The double inner
-- loop cuts down on the number of IMAP operations.
month = {
["Jan"] = "01", ["Feb"] = "02", ["Mar"] = "03",
["Apr"] = "04", ["May"] = "05", ["Jun"] = "06",
["Jul"] = "07", ["Aug"] = "08", ["Sep"] = "09",
["Oct"] = "10", ["Nov"] = "11", ["Dec"] = "12"
}
function archive(days, mailboxes)
for _,mailbox in pairs(mailboxes) do
msgs = myserver[mailbox]:fetch_date(myserver[mailbox]:is_older(days) *
myserver[mailbox]:is_seen() *
myserver[mailbox]:is_unflagged())
if msgs then
mbxs = {}
for msg, date in pairs(msgs) do
_, _, m, y = string.find(date, "%d+-(%a+)-(%d+) ")
mbx = mailbox .. "." .. y .. "." .. month[m]
if mbxs[mbx] == nil then
mbxs[mbx] = {}
end
mbxs[mbx][msg] = true
end
for mbx, msgs in pairs(mbxs) do
myserver[mailbox]:move_messages(myserver[mbx], msgs)
end
end
end
end
archive(120, { "inbox", "ietf", "nanog" })
More information about the Imapfilter-devel
mailing list