summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-01 21:43:46 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-05-01 21:43:46 -0300
commitdcae29a053866613612cfc5a74c8b3c5f3f88e8e (patch)
treea2c03b55aa3e9bce02237f26e08c169fa04ef15b
parent6b2969a63e37eda0eecfdb496cb9392f49e1b762 (diff)
downloadaskbot-dcae29a053866613612cfc5a74c8b3c5f3f88e8e.tar.gz
askbot-dcae29a053866613612cfc5a74c8b3c5f3f88e8e.tar.bz2
askbot-dcae29a053866613612cfc5a74c8b3c5f3f88e8e.zip
added group email address, enabled by default
-rw-r--r--askbot/lamson_handlers.py23
-rw-r--r--askbot/utils/mail.py6
2 files changed, 24 insertions, 5 deletions
diff --git a/askbot/lamson_handlers.py b/askbot/lamson_handlers.py
index f121af06..5c86bc98 100644
--- a/askbot/lamson_handlers.py
+++ b/askbot/lamson_handlers.py
@@ -4,7 +4,7 @@ from lamson.server import Relay
from django.utils.translation import ugettext as _
from django.core.files.uploadedfile import SimpleUploadedFile
from django.conf import settings
-from askbot.models import ReplyAddress
+from askbot.models import ReplyAddress, Tag
from askbot.utils import mail
@@ -113,13 +113,28 @@ def get_parts(message):
parts.append((part_type, part_content))
return parts
-@route('ask@(host)')
+@route('(addr)@(host)')
@stateless
-def ASK(message, host = None):
+def ASK(message, host = None, addr = None):
parts = get_parts(message)
from_address = message.From
subject = message['Subject']#why lamson does not give it normally?
- mail.process_emailed_question(from_address, subject, parts)
+ if addr == 'ask':
+ mail.process_emailed_question(from_address, subject, parts)
+ else:
+ try:
+ group_tag = Tag.group_tags.get(
+ deleted = False,
+ name = addr
+ )
+ mail.process_emailed_question(
+ from_address, subject, parts, tags = [group_tag.name, ]
+ )
+ except Tag.DoesNotExist:
+ #do nothing because this handler will match all emails
+ return
+ except Tag.MultipleObjectsReturned:
+ return
@route('reply-(address)@(host)', address='.+')
@stateless
diff --git a/askbot/utils/mail.py b/askbot/utils/mail.py
index 744c54de..2d4d80b0 100644
--- a/askbot/utils/mail.py
+++ b/askbot/utils/mail.py
@@ -251,7 +251,7 @@ def process_parts(parts):
return body_markdown.strip(), stored_files
-def process_emailed_question(from_address, subject, parts):
+def process_emailed_question(from_address, subject, parts, tags = None):
"""posts question received by email or bounces the message"""
#a bunch of imports here, to avoid potential circular import issues
from askbot.forms import AskByEmailForm
@@ -275,6 +275,10 @@ def process_emailed_question(from_address, subject, parts):
title = form.cleaned_data['title']
body_text = form.cleaned_data['body_text']
+ #defect - here we might get "too many tags" issue
+ if tags:
+ tagnames += ' ' + ' '.join(tags)
+
user.post_question(
title = title,
tags = tagnames,