2018-02-04 03:22:01 +01:00
|
|
|
// 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.
|
2016-11-29 16:23:38 +01:00
|
|
|
|
2019-07-07 02:58:47 +02:00
|
|
|
namespace ircd::m::client_versions
|
|
|
|
{
|
|
|
|
static void append_unstable_features(client &, resource::request &, json::stack &);
|
|
|
|
static void append_versions(client &, resource::request &, json::stack &);
|
|
|
|
static resource::response get(client &, resource::request &);
|
|
|
|
|
2021-01-31 03:15:54 +01:00
|
|
|
extern conf::item<bool> e2ee_forced_public;
|
|
|
|
extern conf::item<bool> e2ee_forced_private;
|
|
|
|
extern conf::item<bool> e2ee_forced_trusted_private;
|
2020-03-31 22:25:13 +02:00
|
|
|
extern conf::item<bool> m_require_identity_server;
|
2020-03-30 22:18:21 +02:00
|
|
|
extern conf::item<bool> org_matrix_e2e_cross_signing;
|
2020-03-30 22:16:27 +02:00
|
|
|
extern conf::item<bool> org_matrix_label_based_filtering;
|
2019-07-07 02:58:47 +02:00
|
|
|
extern conf::item<bool> m_lazy_load_members;
|
|
|
|
extern conf::item<std::string> versions;
|
2019-12-03 20:39:31 +01:00
|
|
|
extern const string_view versions_default;
|
2019-07-07 02:58:47 +02:00
|
|
|
extern resource::method method_get;
|
|
|
|
extern resource resource;
|
|
|
|
}
|
2016-11-29 16:23:38 +01:00
|
|
|
|
2019-07-07 02:58:47 +02:00
|
|
|
ircd::mapi::header
|
2018-02-15 22:06:49 +01:00
|
|
|
IRCD_MODULE
|
|
|
|
{
|
|
|
|
"Client 2.1 :Versions"
|
|
|
|
};
|
|
|
|
|
2019-07-07 02:58:47 +02:00
|
|
|
decltype(ircd::m::client_versions::resource)
|
|
|
|
ircd::m::client_versions::resource
|
2016-11-29 16:23:38 +01:00
|
|
|
{
|
2018-11-06 04:14:53 +01:00
|
|
|
"/_matrix/client/versions",
|
2017-12-12 21:26:39 +01:00
|
|
|
{
|
2018-02-15 22:06:49 +01:00
|
|
|
"(2.1) Gets the versions of the specification supported by the server."
|
2017-12-12 21:26:39 +01:00
|
|
|
}
|
2016-11-29 16:23:38 +01:00
|
|
|
};
|
|
|
|
|
2019-07-07 02:58:47 +02:00
|
|
|
decltype(ircd::m::client_versions::method_get)
|
|
|
|
ircd::m::client_versions::method_get
|
|
|
|
{
|
|
|
|
resource, "GET", get
|
|
|
|
};
|
|
|
|
|
|
|
|
ircd::resource::response
|
|
|
|
ircd::m::client_versions::get(client &client,
|
|
|
|
resource::request &request)
|
2016-11-29 16:23:38 +01:00
|
|
|
{
|
2019-07-07 02:58:47 +02:00
|
|
|
char buf[512];
|
|
|
|
json::stack out{buf};
|
2016-11-29 16:23:38 +01:00
|
|
|
{
|
2019-07-07 02:58:47 +02:00
|
|
|
json::stack::object top{out};
|
|
|
|
append_versions(client, request, out);
|
|
|
|
append_unstable_features(client, request, out);
|
|
|
|
}
|
2016-11-29 16:23:38 +01:00
|
|
|
|
2018-01-08 12:04:49 +01:00
|
|
|
return resource::response
|
|
|
|
{
|
2019-07-07 02:58:47 +02:00
|
|
|
client, json::object
|
|
|
|
{
|
|
|
|
out.completed()
|
|
|
|
}
|
2018-01-08 12:04:49 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-12-03 20:39:31 +01:00
|
|
|
decltype(ircd::m::client_versions::versions_default)
|
|
|
|
ircd::m::client_versions::versions_default
|
|
|
|
{
|
|
|
|
"r0.1.0 "
|
|
|
|
"r0.2.0 "
|
|
|
|
"r0.3.0 "
|
|
|
|
"r0.4.0 "
|
|
|
|
"r0.5.0 "
|
|
|
|
"r0.6.0 "
|
2020-12-11 20:51:18 +01:00
|
|
|
"r0.6.1 "
|
2019-12-03 20:39:31 +01:00
|
|
|
};
|
|
|
|
|
2019-07-07 02:58:47 +02:00
|
|
|
/// Note this conf item doesn't persist to and from the database, which means
|
|
|
|
/// it assumes its default value on every startup.
|
|
|
|
decltype(ircd::m::client_versions::versions)
|
|
|
|
ircd::m::client_versions::versions
|
2018-01-08 12:04:49 +01:00
|
|
|
{
|
2019-12-03 20:39:31 +01:00
|
|
|
{ "name", "ircd.m.client.versions.versions" },
|
|
|
|
{ "persist", false },
|
|
|
|
{ "default", versions_default },
|
2017-03-11 04:31:20 +01:00
|
|
|
};
|
2019-07-07 02:58:47 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
ircd::m::client_versions::append_versions(client &client,
|
|
|
|
resource::request &request,
|
|
|
|
json::stack &out)
|
|
|
|
{
|
|
|
|
json::stack::array array
|
|
|
|
{
|
|
|
|
out, "versions"
|
|
|
|
};
|
|
|
|
|
|
|
|
const string_view &list
|
|
|
|
{
|
|
|
|
versions
|
|
|
|
};
|
|
|
|
|
|
|
|
tokens(list, ' ', [&array]
|
|
|
|
(const string_view &version)
|
|
|
|
{
|
|
|
|
array.append(version);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
decltype(ircd::m::client_versions::m_lazy_load_members)
|
|
|
|
ircd::m::client_versions::m_lazy_load_members
|
|
|
|
{
|
|
|
|
{ "name", "ircd.m.client.versions.m_lazy_load_members" },
|
|
|
|
{ "default", true, },
|
|
|
|
};
|
|
|
|
|
2020-03-30 22:16:27 +02:00
|
|
|
decltype(ircd::m::client_versions::org_matrix_label_based_filtering)
|
|
|
|
ircd::m::client_versions::org_matrix_label_based_filtering
|
|
|
|
{
|
|
|
|
{ "name", "ircd.m.client.versions.org_matrix_label_based_filtering" },
|
|
|
|
{ "default", true, },
|
|
|
|
};
|
|
|
|
|
2020-03-30 22:18:21 +02:00
|
|
|
decltype(ircd::m::client_versions::org_matrix_e2e_cross_signing)
|
|
|
|
ircd::m::client_versions::org_matrix_e2e_cross_signing
|
|
|
|
{
|
|
|
|
{ "name", "ircd.m.client.versions.org_matrix_e2e_cross_signing" },
|
|
|
|
{ "default", true, },
|
|
|
|
};
|
|
|
|
|
2020-03-31 22:25:13 +02:00
|
|
|
decltype(ircd::m::client_versions::m_require_identity_server)
|
|
|
|
ircd::m::client_versions::m_require_identity_server
|
|
|
|
{
|
|
|
|
{ "name", "ircd.m.client.versions.m_require_identity_server" },
|
|
|
|
{ "default", false, },
|
|
|
|
};
|
|
|
|
|
2021-01-31 03:15:54 +01:00
|
|
|
decltype(ircd::m::client_versions::e2ee_forced_public)
|
|
|
|
ircd::m::client_versions::e2ee_forced_public
|
|
|
|
{
|
|
|
|
{ "name", "ircd.m.client.versions.e2ee_forced.public" },
|
|
|
|
{ "default", false, },
|
|
|
|
};
|
|
|
|
|
|
|
|
decltype(ircd::m::client_versions::e2ee_forced_private)
|
|
|
|
ircd::m::client_versions::e2ee_forced_private
|
|
|
|
{
|
|
|
|
{ "name", "ircd.m.client.versions.e2ee_forced.private" },
|
|
|
|
{ "default", false, },
|
|
|
|
};
|
|
|
|
|
|
|
|
decltype(ircd::m::client_versions::e2ee_forced_trusted_private)
|
|
|
|
ircd::m::client_versions::e2ee_forced_trusted_private
|
|
|
|
{
|
|
|
|
{ "name", "ircd.m.client.versions.e2ee_forced.trusted_private" },
|
|
|
|
{ "default", false, },
|
|
|
|
};
|
|
|
|
|
2019-07-07 02:58:47 +02:00
|
|
|
void
|
|
|
|
ircd::m::client_versions::append_unstable_features(client &client,
|
|
|
|
resource::request &request,
|
|
|
|
json::stack &out)
|
|
|
|
{
|
|
|
|
json::stack::object object
|
|
|
|
{
|
|
|
|
out, "unstable_features"
|
|
|
|
};
|
|
|
|
|
|
|
|
// m.lazy_load_members
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
out, "m.lazy_load_members", json::value
|
|
|
|
{
|
|
|
|
bool(m_lazy_load_members)
|
|
|
|
}
|
|
|
|
};
|
2020-03-30 22:16:27 +02:00
|
|
|
|
|
|
|
// org.matrix.label_based_filtering
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
out, "org.matrix.label_based_filtering", json::value
|
|
|
|
{
|
|
|
|
bool(org_matrix_label_based_filtering)
|
|
|
|
}
|
|
|
|
};
|
2020-03-30 22:18:21 +02:00
|
|
|
|
|
|
|
// org.matrix.e2e_cross_signing
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
out, "org.matrix.e2e_cross_signing", json::value
|
|
|
|
{
|
|
|
|
bool(org_matrix_e2e_cross_signing)
|
|
|
|
}
|
|
|
|
};
|
2020-03-31 22:25:13 +02:00
|
|
|
|
|
|
|
// m.require_identity_server
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
out, "m.require_identity_server", json::value
|
|
|
|
{
|
|
|
|
bool(m_require_identity_server)
|
|
|
|
}
|
|
|
|
};
|
2021-01-31 03:15:54 +01:00
|
|
|
|
|
|
|
// e2ee_forced.public
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
out, "io.element.e2ee_forced.public", json::value
|
|
|
|
{
|
|
|
|
bool(e2ee_forced_public)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// e2ee_forced.private
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
out, "io.element.e2ee_forced.private", json::value
|
|
|
|
{
|
|
|
|
bool(e2ee_forced_private)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// e2ee_forced.trusted_private
|
|
|
|
json::stack::member
|
|
|
|
{
|
|
|
|
out, "io.element.e2ee_forced.trusted_private", json::value
|
|
|
|
{
|
|
|
|
bool(e2ee_forced_trusted_private)
|
|
|
|
}
|
|
|
|
};
|
2019-07-07 02:58:47 +02:00
|
|
|
}
|