summaryrefslogtreecommitdiff
path: root/wallace/module_resources.py
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2013-11-25 16:00:03 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-11-25 16:00:03 (GMT)
commitbf10544b4a71929af6593cc2f5002cd547d31a21 (patch)
tree3cd5ce927c237dccccf6d5b340edbbf713bbfb80 /wallace/module_resources.py
parent8f8236df2b81128a45185b3e4b91d24956e2a933 (diff)
downloadpykolab-bf10544b4a71929af6593cc2f5002cd547d31a21.tar.gz
Address #1627 once and for all, by simply not encoding / decoding the message but instead insert the envelope headers
Diffstat (limited to 'wallace/module_resources.py')
-rw-r--r--wallace/module_resources.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index b2924fa..7d45216 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -19,7 +19,6 @@
import datetime
import icalendar
-import json
import os
import pytz
import random
@@ -29,6 +28,7 @@ from urlparse import urlparse
import urllib
from email import message_from_string
+from email.parser import Parser
from email.utils import formataddr
from email.utils import getaddresses
@@ -125,10 +125,11 @@ def execute(*args, **kw):
os.rename(filepath, new_filepath)
filepath = new_filepath
- _message = json.load(open(filepath, 'r'))
- log.debug("Loaded message %r" % (_message), level=9)
- message = message_from_string(str(_message['data']))
- recipients = _message['to']
+ # parse message headers
+ # @TODO: make sure we can use True as the 2nd argument here
+ message = Parser().parse(open(filepath, 'r'), True)
+
+ recipients = [address for displayname,address in getaddresses(message.get_all('X-Kolab-To'))]
any_itips = False
any_resources = False
@@ -449,7 +450,6 @@ def itip_events_from_message(message):
"""
Obtain the iTip payload from email.message <message>
"""
-
# Placeholder for any itip_events found in the message.
itip_events = []
@@ -461,7 +461,6 @@ def itip_events_from_message(message):
# document MUST have (...)" but does not state whether an iTip message must
# therefore also be multipart.
if message.is_multipart():
-
# Check each part
for part in message.walk():