mirror of
https://github.com/matrix-construct/construct
synced 2024-06-10 14:08:56 +02:00
modules/client: Add capabilities endpoint.
This commit is contained in:
parent
2f6384b068
commit
2f088591f7
|
@ -166,6 +166,7 @@ client_client_initialsync_la_SOURCES = client/initialsync.cc
|
|||
client_client_search_la_SOURCES = client/search.cc
|
||||
client_client_joined_groups_la_SOURCES = client/joined_groups.cc
|
||||
client_client_register_available_la_SOURCES = client/register_available.cc
|
||||
client_client_capabilities_la_SOURCES = client/capabilities.cc
|
||||
|
||||
client_module_LTLIBRARIES = \
|
||||
client/client_versions.la \
|
||||
|
@ -188,6 +189,7 @@ client_module_LTLIBRARIES = \
|
|||
client/client_search.la \
|
||||
client/client_joined_groups.la \
|
||||
client/client_register_available.la \
|
||||
client/client_capabilities.la \
|
||||
###
|
||||
|
||||
#
|
||||
|
|
70
modules/client/capabilities.cc
Normal file
70
modules/client/capabilities.cc
Normal file
|
@ -0,0 +1,70 @@
|
|||
// 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 6 :Capabilities Negotiation"
|
||||
};
|
||||
|
||||
resource
|
||||
capabilities_resource
|
||||
{
|
||||
"/_matrix/client/r0/capabilities",
|
||||
{
|
||||
"(6.1) Gets information about the server's supported feature "
|
||||
"set and other relevant capabilities. ",
|
||||
}
|
||||
};
|
||||
|
||||
resource::response
|
||||
get__capabilities(client &client, const resource::request &request)
|
||||
{
|
||||
const bool m_change_password__enabled
|
||||
{
|
||||
mods::loaded("client_account")
|
||||
};
|
||||
|
||||
return resource::response
|
||||
{
|
||||
client, json::members
|
||||
{
|
||||
{ "capabilities", json::members
|
||||
{
|
||||
{ "m.change_password", json::members
|
||||
{
|
||||
{ "enabled", m_change_password__enabled },
|
||||
}},
|
||||
{ "m.room_version", json::members
|
||||
{
|
||||
{ "default", "1" },
|
||||
{ "available", json::members
|
||||
{
|
||||
{ "1", "stable" },
|
||||
{ "2", "unstable" },
|
||||
{ "3", "unstable" },
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
resource::method
|
||||
get_method
|
||||
{
|
||||
capabilities_resource, "GET", get__capabilities,
|
||||
{
|
||||
get_method.REQUIRES_AUTH |
|
||||
get_method.RATE_LIMITED
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue