diff options
-rw-r--r-- | askbot/mail/__init__.py | 14 | ||||
-rw-r--r-- | askbot/mail/lamson_handlers.py | 11 |
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() |