summaryrefslogtreecommitdiffstats
path: root/askbot/mail
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-29 03:15:43 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-29 03:15:43 -0400
commitd6e30bef98ac85a8606284aba4adaf17de811b63 (patch)
tree5bb860eb9c21328a9c791e0c32f868ad49ae89db /askbot/mail
parent8a1e7f47c1aa74d56e0d40ba46d9c771b6ac33eb (diff)
downloadaskbot-d6e30bef98ac85a8606284aba4adaf17de811b63.tar.gz
askbot-d6e30bef98ac85a8606284aba4adaf17de811b63.tar.bz2
askbot-d6e30bef98ac85a8606284aba4adaf17de811b63.zip
hopefully it is possible to edit by email
Diffstat (limited to 'askbot/mail')
-rw-r--r--askbot/mail/lamson_handlers.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/askbot/mail/lamson_handlers.py b/askbot/mail/lamson_handlers.py
index e98e3e99..d803dcf2 100644
--- a/askbot/mail/lamson_handlers.py
+++ b/askbot/mail/lamson_handlers.py
@@ -259,16 +259,18 @@ def VALIDATE_EMAIL(
def PROCESS(
parts = None,
reply_address_object = None,
+ subject_line = None,
**kwargs
):
"""handler to process the emailed message
and make a post to askbot based on the contents of
the email, including the text body and the file attachments"""
- #split email into bits
+ #1) get actual email content
+ # todo: factor this out into the process_reply decorator
reply_code = reply_address_object.address
body_text, stored_files, signature = mail.process_parts(parts, reply_code)
- #if have signature update signature
+ #2) process body text and email signature
user = reply_address_object.user
if signature:#if there, then it was stripped
if signature != user.email_signature:
@@ -281,14 +283,17 @@ def PROCESS(
raise ValueError('email signature changed or unknown')
body_text = stripped_body_text
- #validate email address
+ #3) validate email address and save user
user.email_isvalid = True
user.save()#todo: actually, saving is not necessary, if nothing changed
- #todo: elaborate - here in some cases we want to add an edit
- #and in other cases - replace the text entirely
- if reply_address_object.was_used:
- action = reply_address_object.edit_post
- else:
- action = reply_address_object.create_reply
- action(body_text, stored_files)
+ #4) actually make an edit in the forum
+ robj = reply_address_object
+ add_post_actions = ('post_comment', 'post_answer', 'auto_answer_or_comment')
+ if robj.reply_action in ('replace_content', 'append_content'):
+ robj.edit_post(body_text, title = subject_line)
+ elif robj.reply_action in add_post_actions:
+ if robj.was_used:
+ robj.edit_post(body_text, reply_action = 'append_content')
+ else:
+ robj.create_reply(body_text)