summaryrefslogtreecommitdiff
path: root/py-fake-service/app/adapter/mail_service.py
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-08-14 18:05:37 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-08-14 18:06:06 -0300
commitea88d617a0d6a942850922664590f80d32de7d87 (patch)
tree292c9616a2ab5c6f99215bc9b0c24c7b39bd5416 /py-fake-service/app/adapter/mail_service.py
parent2ee1f78a90fdb47844c8d200ede64169a56e5cbc (diff)
Revert "Enable fake server to correctly serve html emails"
This reverts commit dde0dc6bb735cebe946c6fd8c5d7c8cfd6028cc8.
Diffstat (limited to 'py-fake-service/app/adapter/mail_service.py')
-rw-r--r--py-fake-service/app/adapter/mail_service.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/py-fake-service/app/adapter/mail_service.py b/py-fake-service/app/adapter/mail_service.py
index 41195c0a..7c2570f9 100644
--- a/py-fake-service/app/adapter/mail_service.py
+++ b/py-fake-service/app/adapter/mail_service.py
@@ -16,10 +16,12 @@ class MailService:
def load_mailset(self):
mbox_filenames = [filename for filename in os.listdir(self.MAILSET_PATH) if filename.startswith('mbox')]
- boxes = (mailbox.mbox(os.path.join(self.MAILSET_PATH, mbox)) for mbox in mbox_filenames)
+ boxes = (mailbox.mbox(os.path.join(self.MAILSET_PATH, mbox)) for mbox in mbox_filenames)
for box in boxes:
message = box.popitem()[1]
+ if message.is_multipart():
+ continue
self.mailset.add(message)
self.tagsset.add(message)
self.contacts.add(message)
@@ -47,13 +49,13 @@ class MailService:
def update_tags_for(self, mail_id, new_tags):
mail = self.mail(mail_id)
-
+
new_tags_set = set(new_tags)
old_tags_set = set(mail.tags)
- increment_set = new_tags_set - old_tags_set
+ increment_set = new_tags_set - old_tags_set
decrement_set = old_tags_set - new_tags_set
-
+
map(lambda x : self.tagsset.increment_tag_total_count(x), increment_set)
map(lambda x : self.tagsset.decrement_tag_total_count(x), decrement_set)
@@ -69,8 +71,8 @@ class MailService:
def save_draft(self, mail):
mail = self.mailset.add_draft(Mail.from_json(mail))
return mail.ident
-
-
+
+
def update_draft(self, mail):
mail = Mail.from_json(mail)
self.mailset.update(mail)