summaryrefslogtreecommitdiff
path: root/service/pixelated/controllers
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-11-20 13:43:12 -0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-11-24 08:21:59 -0200
commit4f484e4dd2a40c4b3c71cd3d241785fb3a7b2eaf (patch)
tree09d494d82ac812e87e45c1b1ccc6ff2693b49a62 /service/pixelated/controllers
parentd4b29e22f51c986e4b8306f1782ef3603248d0d5 (diff)
Adding contacts controller and basic contact search
Diffstat (limited to 'service/pixelated/controllers')
-rw-r--r--service/pixelated/controllers/__init__.py1
-rw-r--r--service/pixelated/controllers/contacts_controller.py31
-rw-r--r--service/pixelated/controllers/features_controller.py2
3 files changed, 33 insertions, 1 deletions
diff --git a/service/pixelated/controllers/__init__.py b/service/pixelated/controllers/__init__.py
index e1c13515..33da02b8 100644
--- a/service/pixelated/controllers/__init__.py
+++ b/service/pixelated/controllers/__init__.py
@@ -37,3 +37,4 @@ from tags_controller import TagsController
from features_controller import FeaturesController
from sync_info_controller import SyncInfoController
from attachments_controller import AttachmentsController
+from contacts_controller import ContactsController
diff --git a/service/pixelated/controllers/contacts_controller.py b/service/pixelated/controllers/contacts_controller.py
new file mode 100644
index 00000000..f9b0628b
--- /dev/null
+++ b/service/pixelated/controllers/contacts_controller.py
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2014 ThoughtWorks, Inc.
+#
+# Pixelated is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pixelated is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+
+from pixelated.controllers import respond_json_deferred
+from twisted.internet.threads import deferToThread
+
+
+class ContactsController:
+
+ def __init__(self, search_engine):
+ self._search_engine = search_engine
+
+ def contacts(self, request):
+ query = request.args.get('q', [''])[0]
+ d = deferToThread(lambda: self._search_engine.contacts(query))
+ d.addCallback(lambda tags: respond_json_deferred(tags, request))
+
+ return d \ No newline at end of file
diff --git a/service/pixelated/controllers/features_controller.py b/service/pixelated/controllers/features_controller.py
index 4d375683..f3fa9dff 100644
--- a/service/pixelated/controllers/features_controller.py
+++ b/service/pixelated/controllers/features_controller.py
@@ -19,7 +19,7 @@ import os
class FeaturesController:
- DISABLED_FEATURES = ['draftReply', 'signatureStatus', 'encryptionStatus', 'contacts']
+ DISABLED_FEATURES = ['draftReply', 'signatureStatus', 'encryptionStatus']
def __init__(self):
pass