summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorPatrick Maia <patrickjourdanmaia@gmail.com>2015-02-06 21:03:16 +0000
committerPatrick Maia <patrickjourdanmaia@gmail.com>2015-02-06 21:03:16 +0000
commitff4ebf784e4df248c20d01dcc7e8905aee74d79c (patch)
treed0c8a7fce10ba30f3a36c9aa0d677fda68c6ab61 /service/pixelated/adapter
parentf55a7e5198bfcb8d85c60d86bdf37c18f08c40db (diff)
Issue #276 - saves tags in the same case they arrive
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/services/mail_service.py5
-rw-r--r--service/pixelated/adapter/services/tag_service.py1
2 files changed, 5 insertions, 1 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index 1e0a0414..40a7c6ff 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -35,7 +35,7 @@ class MailService:
return self.querier.mails(mail_ids), total
def update_tags(self, mail_id, new_tags):
- new_tags = [x.lower() for x in map(lambda e: e.strip(), new_tags) if x != '']
+ new_tags = self._filter_white_space_tags(new_tags)
reserved_words = self.tag_service.extract_reserved(new_tags)
if len(reserved_words):
raise ValueError('None of the following words can be used as tags: ' + ' '.join(reserved_words))
@@ -45,6 +45,9 @@ class MailService:
return mail
+ def _filter_white_space_tags(self, tags):
+ return filter(bool, map(lambda e: e.strip(), tags))
+
def mail(self, mail_id):
return self.querier.mail(mail_id)
diff --git a/service/pixelated/adapter/services/tag_service.py b/service/pixelated/adapter/services/tag_service.py
index 22cfb051..601392bb 100644
--- a/service/pixelated/adapter/services/tag_service.py
+++ b/service/pixelated/adapter/services/tag_service.py
@@ -23,4 +23,5 @@ class TagService:
@classmethod
def extract_reserved(cls, tags):
+ tags = map(lambda tag: tag.lower(), tags)
return {tag.name for tag in cls.SPECIAL_TAGS if tag.name in tags}