diff options
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/tag_service.py | 3 | ||||
-rw-r--r-- | service/pixelated/user_agent.py | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/service/pixelated/adapter/tag_service.py b/service/pixelated/adapter/tag_service.py index 874a9a58..f128f1bb 100644 --- a/service/pixelated/adapter/tag_service.py +++ b/service/pixelated/adapter/tag_service.py @@ -59,3 +59,6 @@ class TagService: def all_tags(self): return self.tag_index.values().union(self.SPECIAL_TAGS) + + def all_custom_tags(self): + return self.tag_index.values().difference(self.SPECIAL_TAGS) diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py index 12b9a97a..03372f23 100644 --- a/service/pixelated/user_agent.py +++ b/service/pixelated/user_agent.py @@ -124,12 +124,17 @@ def delete_mails(): @app.route('/tags') def tags(): + tag_service = mail_service.tag_service + query = request.args.get('q') + skipDefaultTags = request.args.get('skipDefaultTags') + + all_tags = tag_service.all_custom_tags() if skipDefaultTags else tag_service.all_tags() if query: - tags = [tag for tag in mail_service.all_tags() if bool(re.match(query, tag.name, re.IGNORECASE))] + tags = [tag for tag in all_tags if bool(re.match(query, tag.name, re.IGNORECASE))] else: - tags = mail_service.all_tags() + tags = all_tags return respond_json([tag.as_dict() for tag in tags]) |