mail: Read mails to roll up from external file

Changed rollup filter to read the files to be rolled up from 'rollup.txt'
file in the imapfilter configuration directory. (by default in XDG
basedir-compliant directory such as '~/.config/imapfilter/rollup.txt')

The file consists of sender addresses with a single address on each
line.
This commit is contained in:
Marty Oehme 2020-09-18 17:10:19 +02:00
parent 698e8a63ee
commit bf80c9ecf3
Signed by: Marty
GPG key ID: B7538B8F50A1C800

View file

@ -1,35 +1,27 @@
function sendToFolder(folderFrom, folderTo, senders) function sendToFolder(folderFrom, folderTo, senders)
for _, sender in pairs(senders) do for _, sender in pairs(senders) do
messages = folderFrom:contain_from(sender) messages = folderFrom:contain_from(sender)
messages:mark_seen() messages:mark_seen()
messages:move_messages(folderTo) messages:move_messages(folderTo)
end end
end end
for _, acc in pairs(accounts) do function getSenderList(file)
sendToFolder ( acc["Inbox"], acc["Dump"], local rollupSenders={}
{
"news@todoist.com", local file = io.open(file)
"server@email.woommart.com", if file then
"noreply@medium.com", for line in file:lines() do
"rollup@unroll.me", table.insert(rollupSenders, line)
"team@readdlenews.com", end
"info@netdata.cloud", else
"taco@trello.com", print("ERROR: rollup did not find rollup.txt file containing mail addresses.")
"quincy@freecodecamp.org", end
"support@instapaper.com", return rollupSenders
"update@author.email.elsevier.com",
"newsletter@cloudflare.com",
"noreply@notify.docker.com",
"hello@skillshare.com",
"noreply@hostelworld.com",
"waitlist@isthereanydeal.com",
"info@mynameisgriz.com",
"news@postman.com",
"no-reply@tumblr.com",
"contact@mailer.humblebundle.com",
"info@audible.de"
})
end end
sendToFolder (
accounts.gmail["Inbox"],
accounts.gmail["Dump"],
getSenderList(getConfigDir() .. "/rollup.txt")
)