aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2016-05-29 23:52:32 +0200
committerVG <vg@devys.org>2016-05-29 23:52:32 +0200
commit34251fd9b354710839b55b1120684071bb40e363 (patch)
tree06a9942f7969b0e65ede6d73319696ce1a6ea69a
parent8bfa1d1bd6d2b29c6a154858cf7a3970d0521b4a (diff)
downloadcliml-34251fd9b354710839b55b1120684071bb40e363.tar.gz
climl-34251fd9b354710839b55b1120684071bb40e363.tar.bz2
climl-34251fd9b354710839b55b1120684071bb40e363.zip
Implement basic rcpt list and send steps
-rw-r--r--climl/hooks.py21
-rw-r--r--climl/interface.py6
2 files changed, 21 insertions, 6 deletions
diff --git a/climl/hooks.py b/climl/hooks.py
index f6e3844..c4840fd 100644
--- a/climl/hooks.py
+++ b/climl/hooks.py
@@ -1,4 +1,4 @@
-from . import interfaces
+from . import interface
def hook_check_ml_restrictions(context, content):
@@ -14,8 +14,23 @@ def hook_process_subscribe_queries(context, content):
def hook_generate_rcpt_list(context, content):
- pass
+ listname = context.get('listname', None)
+ if not listname:
+ raise interface.HookStopIteration('list name not found')
+ recipients_filename = ''.join([listname, '-recipents.txt'])
+ try:
+ with open(recipients_filename, encoding='utf8') as fi:
+ recipients = [recipient for recipient in fi]
+ context['recipients'] = recipients
+ except FileNotFoundError as e:
+ n = interface.HookAbortError('recipients list not found')
+ n.args.append({'listname': listname,
+ 'recipients_filename': recipients_filename})
+ raise n from e
def hook_send_all(context, content):
- pass
+ recipients = context.get('recipients', None)
+ if not recipients:
+ raise interface.HookStopIteration()
+ # TODO: how to send emails here ?
diff --git a/climl/interface.py b/climl/interface.py
index 549eb8b..5bafa2b 100644
--- a/climl/interface.py
+++ b/climl/interface.py
@@ -13,15 +13,15 @@ class HookError(Exception):
class HookAbortError(HookError):
'''
This exception is used to indicate to core of climl it should not mark
- email \Seen for now.
+ email processed for now.
'''
pass
-class HookAbortError(HookError, StopIteration):
+class HookStopIteration(HookError, StopIteration):
'''
Run this if your hook declares it does not want other hooks to process
- email.
+ email. The email will be marked processed.
'''
pass