diff --git a/wallace/module_footer.py b/wallace/module_footer.py --- a/wallace/module_footer.py +++ b/wallace/module_footer.py @@ -85,16 +85,17 @@ if not os.path.isdir(mybasepath): os.makedirs(mybasepath) - for stage in ['incoming', 'ACCEPT']: + for stage in ['incoming']: if not os.path.isdir(os.path.join(mybasepath, stage)): os.makedirs(os.path.join(mybasepath, stage)) + # FIXME: This section of the code is probably not needed since we do not ACCEPT the mail anymore if 'stage' in kw: log.debug(_("Issuing callback after processing to stage %s") % (kw['stage']), level=8) log.debug(_("Testing cb_action_%s()") % (kw['stage']), level=8) if hasattr(modules, 'cb_action_%s' % (kw['stage'])): log.debug(_("Attempting to execute cb_action_%s()") % (kw['stage']), level=8) - exec('modules.cb_action_%s(%r, %r)' % (kw['stage'],'optout',filepath)) + exec('modules.cb_action_%s(%r, %r)' % (kw['stage'],'footer',filepath)) return log.debug(_("Executing module footer for %r, %r") % (args, kw), level=8) @@ -112,8 +113,8 @@ footer = {} footer_position = conf.get('wallace', 'footer_position') - footer_html_file = conf.get('wallace', 'footer_html') - footer_text_file = conf.get('wallace', 'footer_text') + footer_html_file = conf.get('wallace', 'footer_html') or '' + footer_text_file = conf.get('wallace', 'footer_text') or '' sender_exceptions = conf.get('wallace', 'footer_sender_exceptions') if sender_exceptions: @@ -128,14 +129,12 @@ regex = '^<>$' if re.search(regex, sender): - log.debug("Sender matches exception %s" % (item), level=8) - exec('modules.cb_action_%s(%r, %r)' % ('ACCEPT','footer', filepath)) - return + log.debug("Sender matches %s, pass along" % (item), level=8) + return filepath if not os.path.isfile(footer_text_file) and not os.path.isfile(footer_html_file): - log.warning(_("No contents configured for footer module")) - exec('modules.cb_action_%s(%r, %r)' % ('ACCEPT','footer', filepath)) - return + log.warning(_("No contents configured for footer module, pass along")) + return filepath if os.path.isfile(footer_text_file): footer['plain'] = open(footer_text_file, 'r').read() @@ -148,8 +147,7 @@ footer['html'] = '

' + footer['plain'] + '

' if footer['plain'] == "" and footer['html'] == "

": - exec('modules.cb_action_%s(%r, %r)' % ('ACCEPT','footer', filepath)) - return + return filepath footer_added = False @@ -159,8 +157,7 @@ pass if _footer_added == "YES": - exec('modules.cb_action_%s(%r, %r)' % ('ACCEPT','footer', filepath)) - return + return filepath for part in message.walk(): disposition = None @@ -191,12 +188,15 @@ footer_added = set_part_content(part, content) if footer_added: - log.debug("Footer attached.") message.add_header("X-Wallace-Footer", "YES") - (fp, new_filepath) = tempfile.mkstemp(dir="/var/spool/pykolab/wallace/footer/ACCEPT") - os.write(fp, message.as_string()) - os.close(fp) - os.unlink(filepath) + (fp, new_filepath) = tempfile.mkstemp(dir="/var/spool/pykolab/wallace/footer/incoming") - exec('modules.cb_action_%s(%r, %r)' % ('ACCEPT','footer', new_filepath)) + log.debug("Footer attached, saving mail to %s and passing along" % (new_filepath), level=8) + + os.write(fp, message.as_string()) + os.close(fp) + os.unlink(filepath) + filepath = new_filepath + + return filepath