summary refs log tree commit diff
path: root/synapse/rest/client/v1
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-10-19 13:37:15 +0100
committerErik Johnston <erik@matrix.org>2015-10-19 13:37:15 +0100
commite0bf0258eeef08bac0930652a3557fddc1021659 (patch)
treed23be2d3097493e190a0c320528a730d99e9f20d /synapse/rest/client/v1
parentMerge pull request #313 from matrix-org/paul/tiny-fixes (diff)
parentExplicitly check for Sqlite3Engine (diff)
downloadsynapse-e0bf0258eeef08bac0930652a3557fddc1021659.tar.xz
Merge pull request #307 from matrix-org/erikj/search
Add basic search API
Diffstat (limited to 'synapse/rest/client/v1')
-rw-r--r--synapse/rest/client/v1/room.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py
index 1f45fcc6f1..4cee1c1599 100644
--- a/synapse/rest/client/v1/room.py
+++ b/synapse/rest/client/v1/room.py
@@ -555,6 +555,22 @@ class RoomTypingRestServlet(ClientV1RestServlet):
         defer.returnValue((200, {}))
 
 
+class SearchRestServlet(ClientV1RestServlet):
+    PATTERN = client_path_pattern(
+        "/search$"
+    )
+
+    @defer.inlineCallbacks
+    def on_POST(self, request):
+        auth_user, _ = yield self.auth.get_user_by_req(request)
+
+        content = _parse_json(request)
+
+        results = yield self.handlers.search_handler.search(auth_user, content)
+
+        defer.returnValue((200, results))
+
+
 def _parse_json(request):
     try:
         content = json.loads(request.content.read())
@@ -611,3 +627,4 @@ def register_servlets(hs, http_server):
     RoomInitialSyncRestServlet(hs).register(http_server)
     RoomRedactEventRestServlet(hs).register(http_server)
     RoomTypingRestServlet(hs).register(http_server)
+    SearchRestServlet(hs).register(http_server)