summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Iannetta <paul.iannetta@ens-lyon.fr>2022-04-21 23:39:28 +0200
committerPaul Iannetta <paul.iannetta@ens-lyon.fr>2022-04-21 23:39:28 +0200
commite5cb4057fda66962ccb710b460a363bd8aab7414 (patch)
treeb2f06360231f733ca832b86cd0e7f684ab5bf2e3
parent580859ae5ceb66280137256c0dbd8ba4744df169 (diff)
add offlineimap & imapfilter confs
-rwxr-xr-x.config/imapfilter/accounts.lua44
-rwxr-xr-x.config/imapfilter/collaborators.lua5
-rwxr-xr-x.config/imapfilter/ens.lua16
-rwxr-xr-x.config/imapfilter/imapfilter-common.lua30
-rwxr-xr-x.config/imapfilter/inria.lua27
-rwxr-xr-x[-rw-r--r--].config/offlineimap/offlineimap.py0
-rwxr-xr-x.config/offlineimap/offlineimaprc.template44
7 files changed, 166 insertions, 0 deletions
diff --git a/.config/imapfilter/accounts.lua b/.config/imapfilter/accounts.lua
new file mode 100755
index 0000000..1eb6b17
--- /dev/null
+++ b/.config/imapfilter/accounts.lua
@@ -0,0 +1,44 @@
+-- function get_inria_handle()
+-- return IMAP {
+-- server = 'zimbra.inria.fr',
+-- username = get_imap_username('inria'),
+-- password = get_imap_password('inria'),
+-- ssl = 'ssl3',
+-- }
+-- end
+
+-- function get_ensl_handle()
+-- return IMAP {
+-- server = 'imaps.ens-lyon.fr',
+-- username = get_imap_username('ensl'),
+-- password = get_imap_password('ensl'),
+-- ssl = 'ssl3',
+-- }
+-- end
+
+function get_inria_handle()
+ return IMAP {
+ server = 'localhost',
+ username = 'inria',
+ password = '',
+ port = 10143,
+ }
+end
+
+function get_ensl_handle()
+ return IMAP {
+ server = 'localhost',
+ username = 'ens',
+ password = '',
+ port = 10143,
+ }
+end
+
+function get_archives_handle()
+ return IMAP {
+ server = 'localhost',
+ username = 'archives',
+ password = '',
+ port = 10143,
+ }
+end
diff --git a/.config/imapfilter/collaborators.lua b/.config/imapfilter/collaborators.lua
new file mode 100755
index 0000000..c0bca01
--- /dev/null
+++ b/.config/imapfilter/collaborators.lua
@@ -0,0 +1,5 @@
+function get_collaborators()
+ return {
+ { first = "first name" , last = "last name" },
+ }
+end
diff --git a/.config/imapfilter/ens.lua b/.config/imapfilter/ens.lua
new file mode 100755
index 0000000..8a1b42c
--- /dev/null
+++ b/.config/imapfilter/ens.lua
@@ -0,0 +1,16 @@
+package.path = package.path .. ";" .. os.getenv("HOME") .. "/.config/imapfilter/?.lua"
+
+require 'imapfilter-common'
+require 'accounts'
+
+ensl = get_ensl_handle()
+
+mails = ensl['INBOX']:select_all()
+
+boost = mails:contain_field('Sender', 'boost')
+clang = mails:contain_field('Sender', 'llvm')
+gcc = mails:contain_field('Sender', 'gcc')
+
+gcc : move_messages(ensl["INBOX.topics.gcc"])
+clang : move_messages(ensl["INBOX.topics.clang"])
+boost : move_messages(ensl["INBOX.topics.boost"])
diff --git a/.config/imapfilter/imapfilter-common.lua b/.config/imapfilter/imapfilter-common.lua
new file mode 100755
index 0000000..8460bb0
--- /dev/null
+++ b/.config/imapfilter/imapfilter-common.lua
@@ -0,0 +1,30 @@
+-- Utility function to get IMAP username from pass
+function get_imap_username(account)
+ local str = io.popen('pass institutions/' .. account .. '/id'):read()
+ return str;
+end
+
+-- Utility function to get IMAP password from pass
+function get_imap_password(account)
+ local str = io.popen('pass institutions/' .. account .. '/pass'):read()
+ return str;
+end
+
+-- https://stackoverflow.com/a/11402486
+function case_insensitive_pattern(pattern)
+
+ -- find an optional '%' (group 1) followed by any character (group 2)
+ local p = pattern:gsub("(%%?)(.)", function(percent, letter)
+
+ if percent ~= "" or not letter:match("%a") then
+ -- if the '%' matched, or `letter` is not a letter, return "as is"
+ return percent .. letter
+ else
+ -- else, return a case-insensitive character class of the matched letter
+ return string.format("[%s%s]", letter:lower(), letter:upper())
+ end
+
+ end)
+
+ return p
+end
diff --git a/.config/imapfilter/inria.lua b/.config/imapfilter/inria.lua
new file mode 100755
index 0000000..b8ea7f1
--- /dev/null
+++ b/.config/imapfilter/inria.lua
@@ -0,0 +1,27 @@
+package.path = package.path .. ";" .. os.getenv("XDG_CONFIG_HOME") .. "/imapfilter/?.lua"
+
+require 'imapfilter-common'
+require 'collaborators'
+require 'accounts'
+
+inria = get_inria_handle()
+ensl = get_ensl_handle()
+
+mails = inria['INBOX']:select_all()
+
+-- reforwarding of mails that should have been sent to ensl account
+
+igitlab = mails:match_from('gitlab')
+igitlab:move_messages(ensl['INBOX'])
+
+collaborators = get_collaborators()
+
+for i,c in pairs(collaborators) do
+ c_pat = case_insensitive_pattern(".*" .. c["first"] .. "[. ]" .. c["last"] .. ".*")
+ to_move = mails:match_from(c_pat) + mails:match_to(c_pat)
+ to_move:move_messages(ensl['INBOX'])
+
+ c_pat = case_insensitive_pattern(".*" .. c["last"] .. "[. ]" .. c["first"] .. ".*")
+ to_move = mails:match_from(c_pat) + mails:match_to(c_pat)
+ to_move:move_messages(ensl['INBOX'])
+end
diff --git a/.config/offlineimap/offlineimap.py b/.config/offlineimap/offlineimap.py
index 3cc7f17..3cc7f17 100644..100755
--- a/.config/offlineimap/offlineimap.py
+++ b/.config/offlineimap/offlineimap.py
diff --git a/.config/offlineimap/offlineimaprc.template b/.config/offlineimap/offlineimaprc.template
new file mode 100755
index 0000000..d6cae15
--- /dev/null
+++ b/.config/offlineimap/offlineimaprc.template
@@ -0,0 +1,44 @@
+[general]
+pythonfile = ~/.config/offlineimap/offlineimap.py
+# accounts = account1, account2
+accounts = account1
+maxsyncaccounts = 3
+socktimeout = 60
+ui = Quiet
+
+[mbnames]
+# Create a list of available mailboxes for mutt
+enabled = yes
+
+filename = ~/.config/mutt/muttmailboxes
+header = "mailboxes "
+peritem = "+%(accountname)s/%(foldername)s"
+sep = " "
+footer = "\n"
+
+# Exclude these mailboxes from the above mailbox list
+folderfilter = lambda accountname, foldername: not re.search('(.*&AMk-.*|^bak.*|.*drafts$|.*spam$|.*sent$|.*trash$)', foldername)
+
+[Account account1]
+localrepository = local-account1
+remoterepository = remote-account1
+presynchook = /usr/bin/imapfilter -vc ~/.config/imapfilter/account1.lua
+postsynchook = notmuch new
+# proceed with care
+# utf8foldernames = yes
+
+[Repository local-account1]
+type = Maildir
+localfolders = ~/.mail/account1
+
+[Repository remote-account1]
+type = IMAP
+ssl = yes
+remotehost = imap....
+remoteport = 993
+remoteuser = account1
+remotepasseval = get_pass("path/to/pass")
+sslcacertfile = /etc/ssl/certs/ca-certificates.crt
+#subscribedonly = yes
+
+# vim: ft=dosini