aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--climl/imap.py8
-rw-r--r--climl/interface.py19
2 files changed, 26 insertions, 1 deletions
diff --git a/climl/imap.py b/climl/imap.py
index 68a6e9b..034c77a 100644
--- a/climl/imap.py
+++ b/climl/imap.py
@@ -7,6 +7,8 @@ import backports.ssl as ssl
import socket
import time
+from . import interface
+
def conf_boolean_postprocess(src):
src = src.lower().strip()
if src == 'true' or src == 'on' or src == '1':
@@ -143,7 +145,11 @@ def main(callback=None):
response = connection.fetch([oneid], ['RFC822'])
data = response[oneid][b'RFC822']
print('calling callback...')
- callback('mail: ' + str(oneid) + ': ' + str(data))
+ try:
+ callback('mail: ' + str(oneid) + ': ' + str(data))
+ connection.add_flags([oneid], ['\Seen'])
+ except interface.HookAbortError:
+ pass
data = None
while True:
imap_waiter(connection)
diff --git a/climl/interface.py b/climl/interface.py
new file mode 100644
index 0000000..5a7f6ba
--- /dev/null
+++ b/climl/interface.py
@@ -0,0 +1,19 @@
+'''
+This file defines symbols used to make communication between
+hooks/plugins/extensions and core of climl.
+'''
+
+class HookError(Exception):
+ '''
+ Base class for hooks exception, they should not use this directly
+ '''
+
+ pass
+
+class HookAbortError(HookError):
+ '''
+ This exception is used to indicate to core of climl it should not mark
+ email \Seen for now.
+ '''
+
+ pass