summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-10-31 00:35:40 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-10-31 00:35:40 -0300
commitacf0d4273e229f8352c0b8dab2f873073ddf147b (patch)
tree537b2576c1ebc677eb3855e61e771346038ddf66
parent6c4e201e36bf1d8270562f70018d29b40be1ebf3 (diff)
downloadaskbot-acf0d4273e229f8352c0b8dab2f873073ddf147b.tar.gz
askbot-acf0d4273e229f8352c0b8dab2f873073ddf147b.tar.bz2
askbot-acf0d4273e229f8352c0b8dab2f873073ddf147b.zip
added logging of response boundaries in the emailed responses
-rw-r--r--askbot/mail/__init__.py26
-rw-r--r--askbot/models/tag.py1
-rw-r--r--askbot/tasks.py1
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))
-