diff options
Diffstat (limited to 'climl/hooks.py')
-rw-r--r-- | climl/hooks.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/climl/hooks.py b/climl/hooks.py index cf8ae9d..fcc43f4 100644 --- a/climl/hooks.py +++ b/climl/hooks.py @@ -2,32 +2,44 @@ import smtplib from . import interface -def hook_extract_listname(context, content): - print('hook_extract_listname:') - print(content) - - -def hook_check_ml_restrictions(context, content): +def hook_extract_listname(context): + lines = content.split(b'\n') + for line in lines: + print('line: ', line) + if line.startswith(b'Delivered-To: '): + listname = line.split()[1].decode('ascii') + context['listname'] = listname + print('found listname: {}'.format(listname)) + return + raise interface.HookAbortError('listname not found') + + +def hook_check_ml_restrictions(context): pass -def hook_validate_poster(context, content): +def hook_validate_poster(context): pass -def hook_process_subscribe_queries(context, content): +def hook_process_subscribe_queries(context): pass -def hook_generate_rcpt_list(context, content): +def hook_generate_rcpt_list(context): + print(1) listname = context.get('listname', None) + print(2) if not listname: raise interface.HookStopIteration('list name not found') + print(3) recipients_filename = ''.join([listname, '-recipents.txt']) + print(4) try: with open(recipients_filename, encoding='utf8') as fi: recipients = [recipient for recipient in fi] context['recipients'] = recipients + print(5) except FileNotFoundError as e: n = interface.HookAbortError('recipients list not found') n.args.append({'listname': listname, @@ -35,7 +47,7 @@ def hook_generate_rcpt_list(context, content): raise n from e -def hook_send_all(context, content): +def hook_send_all(context): listaddress = context.get('listaddress', None) if not listaddress: raise interface.HookStopIteration('list address not found') |