mirror of
https://github.com/matrix-construct/construct
synced 2024-11-28 17:52:54 +01:00
modules/client: Stub search endpoint.
This commit is contained in:
parent
46aec8bc8f
commit
52767c836f
2 changed files with 68 additions and 0 deletions
|
@ -128,6 +128,7 @@ client_client_directory_room_la_SOURCES = client/directory/room.cc
|
|||
client_client_directory_user_la_SOURCES = client/directory/user.cc
|
||||
client_client_publicised_groups_la_SOURCES = client/publicised_groups.cc
|
||||
client_client_initialsync_la_SOURCES = client/initialsync.cc
|
||||
client_client_search_la_SOURCES = client/search.cc
|
||||
|
||||
client_module_LTLIBRARIES = \
|
||||
client/client_versions.la \
|
||||
|
@ -150,6 +151,7 @@ client_module_LTLIBRARIES = \
|
|||
client/client_directory_user.la \
|
||||
client/client_publicised_groups.la \
|
||||
client/client_initialsync.la \
|
||||
client/client_search.la \
|
||||
###
|
||||
|
||||
#
|
||||
|
|
66
modules/client/search.cc
Normal file
66
modules/client/search.cc
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
using namespace ircd;
|
||||
|
||||
mapi::header
|
||||
IRCD_MODULE
|
||||
{
|
||||
"Client 11.14 :Server Side Search"
|
||||
};
|
||||
|
||||
resource
|
||||
search
|
||||
{
|
||||
"/_matrix/client/r0/search",
|
||||
{
|
||||
"(11.14.1) The search API allows clients to perform full text search"
|
||||
" across events in all rooms that the user has been in, including"
|
||||
" those that they have left. Only events that the user is allowed to"
|
||||
" see will be searched, e.g. it won't include events in rooms that"
|
||||
" happened after you left."
|
||||
}
|
||||
};
|
||||
|
||||
resource::response
|
||||
post__search(client &client, const resource::request &request)
|
||||
{
|
||||
const auto &batch
|
||||
{
|
||||
request.query["next_batch"]
|
||||
};
|
||||
|
||||
int64_t count(0);
|
||||
const string_view next_batch{};
|
||||
|
||||
return resource::response
|
||||
{
|
||||
client, json::members
|
||||
{
|
||||
{ "search_categories", json::members
|
||||
{
|
||||
{ "room_events", json::members
|
||||
{
|
||||
{ "count", count },
|
||||
{ "results", json::array{} },
|
||||
{ "state", json::object{} },
|
||||
{ "groups", json::object{} },
|
||||
{ "next_batch", next_batch },
|
||||
}}
|
||||
}}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
resource::method
|
||||
post_method
|
||||
{
|
||||
search, "POST", post__search
|
||||
};
|
Loading…
Reference in a new issue