summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorKlaus Fl <kfleerko@thoughtworks.com>2015-08-07 17:19:25 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:33 +0200
commit319e5e2ddd20444bb30f294a2fd08854dfaae494 (patch)
tree1d341aca9bb601170414275f0cc90b3e19b22359 /service/pixelated
parent8585a186716a4f45132e3c9eea90a792ca76c2a2 (diff)
Make indexing recepients work again by fixing serialization bug
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py15
-rw-r--r--service/pixelated/adapter/model/mail.py5
-rw-r--r--service/pixelated/adapter/services/mail_service.py3
-rw-r--r--service/pixelated/resources/contacts_resource.py10
4 files changed, 26 insertions, 7 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index c34d2b16..049af9ee 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -27,12 +27,21 @@ class LeapMail(Mail):
def __init__(self, mail_id, mailbox_name, headers=None, tags=set(), flags=set(), body=None):
self._mail_id = mail_id
self._mailbox_name = mailbox_name
- self.headers = headers if headers is not None else {}
+ self._headers = headers if headers is not None else {}
self._body = body
self.tags = tags
self._flags = flags
@property
+ def headers(self):
+ cpy = dict(self._headers)
+
+ for name in set(self._headers.keys()).intersection(['To', 'Cc', 'Bcc']):
+ cpy[name] = self._headers[name].split(',') if self._headers[name] else None
+
+ return cpy
+
+ @property
def ident(self):
return self._mail_id
@@ -55,7 +64,7 @@ class LeapMail(Mail):
@property
def raw(self):
result = ''
- for k, v in self.headers.items():
+ for k, v in self._headers.items():
result = result + '%s: %s\n' % (k, v)
result = result + '\n'
if self._body:
@@ -197,7 +206,7 @@ class LeapMailStore(MailStore):
mbox_uuid = message.get_wrapper().fdoc.mbox_uuid
mbox_name = yield self._mailbox_name_from_uuid(mbox_uuid)
- mail = LeapMail(mail_id, mbox_name, message.get_headers(), set(message.get_tags()), body=body)
+ mail = LeapMail(mail_id, mbox_name, message.get_wrapper().hdoc.headers, set(message.get_tags()), body=body)
defer.returnValue(mail)
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 61e56f33..388263ca 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -95,7 +95,10 @@ class Mail(object):
return self._mime
mime = MIMEMultipart()
for key, value in self.headers.items():
- mime[str(key)] = str(value)
+ if isinstance(value, list):
+ mime[str(key)] = ', '.join(value)
+ else:
+ mime[str(key)] = str(value)
try:
body_to_use = self.body
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index 5e4d7a6d..6b011e11 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -112,8 +112,7 @@ class MailService(object):
if mail.mailbox_name.upper() == u'TRASH':
yield self.mail_store.delete_mail(mail_id)
else:
- trashed_mail = yield self.mail_store.move_mail_to_mailbox(mail_id, 'TRASH')
- self.search_engine.index_mail(trashed_mail)
+ yield self.mail_store.move_mail_to_mailbox(mail_id, 'TRASH')
def recover_mail(self, mail_id):
recovered_mail = self.mailboxes.move_to_inbox(mail_id)
diff --git a/service/pixelated/resources/contacts_resource.py b/service/pixelated/resources/contacts_resource.py
index 5ec39761..c9b81f54 100644
--- a/service/pixelated/resources/contacts_resource.py
+++ b/service/pixelated/resources/contacts_resource.py
@@ -29,8 +29,16 @@ class ContactsResource(Resource):
self._search_engine = search_engine
def render_GET(self, request):
- query = request.args.get('q', [''])[0]
+ query = request.args.get('q', [''])
d = deferToThread(lambda: self._search_engine.contacts(query))
d.addCallback(lambda tags: respond_json_deferred(tags, request))
+ def handle_error(error):
+ print 'Something went wrong'
+ import traceback
+ traceback.print_exc()
+ print error
+
+ d.addErrback(handle_error)
+
return server.NOT_DONE_YET