From eee3ec8b7d78a04f4b3f8a56c7f73797318c9dd0 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 24 May 2012 15:09:51 -0400 Subject: added signature stripping to posting of responses by email --- askbot/models/__init__.py | 3 +++ askbot/models/reply_by_email.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index 90336e6c..d7b838d5 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -207,6 +207,9 @@ def user_update_avatar_type(self): def user_strip_email_signature(self, text): """strips email signature from the end of the text""" + if self.email_signature == '': + return text + text = '\n'.join(text.splitlines())#normalize the line endings if text.endswith(self.email_signature): return text[0:-len(self.email_signature)] diff --git a/askbot/models/reply_by_email.py b/askbot/models/reply_by_email.py index 4398f693..786b38a5 100644 --- a/askbot/models/reply_by_email.py +++ b/askbot/models/reply_by_email.py @@ -79,6 +79,7 @@ class ReplyAddress(models.Model): to the same address""" assert self.was_used == True content, stored_files = mail.process_parts(parts) + content = self.user.strip_email_signature(content) self.user.edit_post( post = self.response_post, body_text = content, @@ -94,6 +95,7 @@ class ReplyAddress(models.Model): result = None #todo: delete stored files if this function fails content, stored_files = mail.process_parts(parts) + content = self.user.strip_email_signature(content) if self.post.post_type == 'answer': result = self.user.post_comment( -- cgit v1.2.3-1-g7c22