From acf0d4273e229f8352c0b8dab2f873073ddf147b Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 31 Oct 2012 00:35:40 -0300 Subject: added logging of response boundaries in the emailed responses --- askbot/mail/__init__.py | 26 +++++++++++++++----------- askbot/models/tag.py | 1 - askbot/tasks.py | 1 - 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/askbot/mail/__init__.py b/askbot/mail/__init__.py index 74aa27e9..7d426e80 100644 --- a/askbot/mail/__init__.py +++ b/askbot/mail/__init__.py @@ -82,16 +82,15 @@ def thread_headers(post, orig_post, update): return headers def clean_html_email(email_body): - '''needs more clenup might not work for other email templates - that does not use table layout''' - - remove_linejump = lambda s: s.replace('\n', '') - + """needs more clenup might not work for other email templates + that do not use table layout + """ soup = BeautifulSoup(email_body) - table_tds = soup.find('body') - phrases = map(lambda s: s.strip(), - filter(bool, table_tds.get_text().split('\n'))) - + body_element = soup.find('body') + phrases = map( + lambda s: s.strip(), + filter(bool, body_element.get_text().split('\n')) + ) return '\n\n'.join(phrases) def send_mail( @@ -266,10 +265,15 @@ def bounce_email( def extract_reply(text): """take the part above the separator - and discard the last line above the separator""" + and discard the last line above the separator + """ if const.REPLY_SEPARATOR_REGEX.search(text): text = const.REPLY_SEPARATOR_REGEX.split(text)[0] - return '\n'.join(text.splitlines(True)[:-3]) + text_lines = text.splitlines(False) + #log last 10 lines of text - to capture email responses + logging.debug('reply-border-separator|' + '|'.join(text_lines[-10:])) + #here we need code stripping the "On ... somebody wrote:" + return '\n'.join(text_lines[:-3]) else: return text diff --git a/askbot/models/tag.py b/askbot/models/tag.py index d7e91eb5..e4c4540a 100644 --- a/askbot/models/tag.py +++ b/askbot/models/tag.py @@ -1,5 +1,4 @@ import re -import logging from django.db import models from django.contrib.auth.models import User from django.utils.translation import ugettext as _ diff --git a/askbot/tasks.py b/askbot/tasks.py index 505597d2..5cdd59b7 100644 --- a/askbot/tasks.py +++ b/askbot/tasks.py @@ -243,4 +243,3 @@ def send_instant_notifications_about_activity_in_post( ) else: logger.debug('success %s, logId=%s' % (user.email, log_id)) - -- cgit v1.2.3-1-g7c22