diff options
Diffstat (limited to 'climl/hooks.py')
-rw-r--r-- | climl/hooks.py | 21 |
1 files changed, 18 insertions, 3 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 ? |