summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-04-24 01:03:51 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-04-24 01:03:51 -0400
commitb82f91b7d86967b19a069497035226e4d4d8595d (patch)
tree8fda6c40da980f91bab7a3cffd806dfdfda1c043
parentaa678c13b753ab37e08c0171bef1953119b9c2a3 (diff)
downloadaskbot-b82f91b7d86967b19a069497035226e4d4d8595d.tar.gz
askbot-b82f91b7d86967b19a069497035226e4d4d8595d.tar.bz2
askbot-b82f91b7d86967b19a069497035226e4d4d8595d.zip
made changes in the code responsible for detecting email signature
-rw-r--r--askbot/mail/__init__.py14
-rw-r--r--askbot/mail/lamson_handlers.py11
2 files changed, 20 insertions, 5 deletions
diff --git a/askbot/mail/__init__.py b/askbot/mail/__init__.py
index 74c2acbd..352711b6 100644
--- a/askbot/mail/__init__.py
+++ b/askbot/mail/__init__.py
@@ -379,14 +379,20 @@ def process_emailed_question(
raise PermissionDenied(messages.insufficient_reputation(user))
body_text = form.cleaned_data['body_text']
+
stripped_body_text = user.strip_email_signature(body_text)
- signature_not_detected = (
- stripped_body_text == body_text and user.email_signature
- )
+ signature_not_detected = (stripped_body_text == body_text)
+
+ need_new_signature = (
+ user.email_isvalid is False or
+ user.email_signature == '' or
+ signature_not_detected
+ )
+
#ask for signature response if user's email has not been
#validated yet or if email signature could not be found
- if user.email_isvalid is False or signature_not_detected:
+ if need_new_signature:
reply_to = ReplyAddress.objects.create_new(
user = user,
diff --git a/askbot/mail/lamson_handlers.py b/askbot/mail/lamson_handlers.py
index 65e5fde0..81dd997f 100644
--- a/askbot/mail/lamson_handlers.py
+++ b/askbot/mail/lamson_handlers.py
@@ -228,9 +228,18 @@ def VALIDATE_EMAIL(
reply_code = reply_address_object.address
try:
content, stored_files, signature = mail.process_parts(parts, reply_code)
+
+ #patch signature to a sentinel value if it is truly empty, because we
+ #cannot allow empty signature field, which indicates no
+ #signature at all and in that case we ask user to create one
+ if signature == '':
+ signature = 'empty signature'
+
user = reply_address_object.user
- if signature and signature != user.email_signature:
+
+ if signature != user.email_signature:
user.email_signature = signature
+
user.email_isvalid = True
user.save()