diff options
author | Erik Johnston <erik@matrix.org> | 2015-10-19 13:37:15 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-10-19 13:37:15 +0100 |
commit | e0bf0258eeef08bac0930652a3557fddc1021659 (patch) | |
tree | d23be2d3097493e190a0c320528a730d99e9f20d /synapse/rest | |
parent | Merge pull request #313 from matrix-org/paul/tiny-fixes (diff) | |
parent | Explicitly check for Sqlite3Engine (diff) | |
download | synapse-e0bf0258eeef08bac0930652a3557fddc1021659.tar.xz |
Merge pull request #307 from matrix-org/erikj/search
Add basic search API
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/client/v1/room.py | 17 |
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) |