mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 01:30:12 +01:00
ircd:Ⓜ️🆔 Support intuitive constructions of m::node::id.
This commit is contained in:
parent
4f3f729d9b
commit
da8beda0c3
8 changed files with 45 additions and 26 deletions
|
@ -92,8 +92,8 @@ enum ircd::m::id::sigil
|
|||
ROOM = '!', ///< Room ID (4.2.2)
|
||||
ROOM_ALIAS = '#', ///< Room alias (4.2.3)
|
||||
GROUP = '+', ///< Group ID (experimental)
|
||||
NODE = ':', ///< Node ID (experimental)
|
||||
DEVICE = '%', ///< Device ID (experimental)
|
||||
NODE = ':', ///< Node ID (experimental)
|
||||
};
|
||||
|
||||
/// (Appendix 4.2.1) User Identifiers
|
||||
|
@ -205,21 +205,6 @@ struct ircd::m::id::group
|
|||
group() = default;
|
||||
};
|
||||
|
||||
/// Node ID (EXPERIMENTAL)
|
||||
///
|
||||
struct ircd::m::id::node
|
||||
:ircd::m::id
|
||||
{
|
||||
using buf = m::id::buf<node>;
|
||||
|
||||
template<class... args>
|
||||
node(args&&... a)
|
||||
:m::id{NODE, std::forward<args>(a)...}
|
||||
{}
|
||||
|
||||
node() = default;
|
||||
};
|
||||
|
||||
/// Device ID (EXPERIMENTAL)
|
||||
///
|
||||
struct ircd::m::id::device
|
||||
|
@ -235,6 +220,30 @@ struct ircd::m::id::device
|
|||
device() = default;
|
||||
};
|
||||
|
||||
/// Node ID (EXPERIMENTAL)
|
||||
///
|
||||
struct ircd::m::id::node
|
||||
:ircd::m::id
|
||||
{
|
||||
using buf = m::id::buf<node>;
|
||||
|
||||
IRCD_OVERLOAD(domain)
|
||||
node(const mutable_buffer &mb, domain_t, const string_view &domain_, const string_view &origin_)
|
||||
:m::id{NODE, mb, domain_, origin_}
|
||||
{}
|
||||
|
||||
IRCD_OVERLOAD(origin)
|
||||
node(const mutable_buffer &mb, origin_t, const string_view &origin_)
|
||||
:m::id{NODE, mb, string_view{}, origin_}
|
||||
{}
|
||||
|
||||
node(const string_view &id)
|
||||
:m::id{NODE, id}
|
||||
{}
|
||||
|
||||
node() = default;
|
||||
};
|
||||
|
||||
// Utilities
|
||||
namespace ircd::m
|
||||
{
|
||||
|
|
|
@ -735,7 +735,7 @@ try
|
|||
{
|
||||
const m::node::id::buf node_id
|
||||
{
|
||||
"", origin
|
||||
m::node::id::origin, origin
|
||||
};
|
||||
|
||||
const m::node node
|
||||
|
|
|
@ -330,7 +330,7 @@ ircd::m::my_room
|
|||
ircd::m::node::id::buf
|
||||
ircd_node_id
|
||||
{
|
||||
"", "localhost" // replaced after conf init
|
||||
ircd::m::node::id::origin, "localhost" // replaced after conf init
|
||||
};
|
||||
|
||||
ircd::m::node
|
||||
|
@ -370,7 +370,7 @@ ircd::m::self::init::init(const string_view &origin)
|
|||
ircd_room_id = {"ircd", origin};
|
||||
m::my_room = {ircd_room_id};
|
||||
|
||||
ircd_node_id = {"", origin};
|
||||
ircd_node_id = {node::id::origin, origin};
|
||||
m::my_node = {ircd_node_id};
|
||||
|
||||
users_room_id = {"users", origin};
|
||||
|
|
|
@ -181,7 +181,7 @@ const
|
|||
|
||||
const m::node::id::buf node_id
|
||||
{
|
||||
"", unquote(at<"origin"_>(*this))
|
||||
m::node::id::origin, unquote(at<"origin"_>(*this))
|
||||
};
|
||||
|
||||
const m::node node
|
||||
|
|
|
@ -267,7 +267,7 @@ try
|
|||
"The X-Matrix Authorization is invalid."
|
||||
};
|
||||
|
||||
request.node_id = {"", x_matrix.origin};
|
||||
request.node_id = {m::node::id::origin, x_matrix.origin};
|
||||
request.origin = x_matrix.origin;
|
||||
|
||||
// If we have an error cached from previously not being able to
|
||||
|
|
|
@ -6948,9 +6948,14 @@ console_cmd__node__keys(opt &out, const string_view &line)
|
|||
"node_id", "[limit]"
|
||||
}};
|
||||
|
||||
const m::node::id::buf node_id
|
||||
{
|
||||
m::node::id::origin, param.at(0)
|
||||
};
|
||||
|
||||
const m::node &node
|
||||
{
|
||||
param.at(0)
|
||||
node_id
|
||||
};
|
||||
|
||||
auto limit
|
||||
|
@ -6983,9 +6988,14 @@ console_cmd__node__key(opt &out, const string_view &line)
|
|||
"node_id", "key_id"
|
||||
}};
|
||||
|
||||
const m::node::id::buf node_id
|
||||
{
|
||||
m::node::id::origin, param.at(0)
|
||||
};
|
||||
|
||||
const m::node &node
|
||||
{
|
||||
param.at(0)
|
||||
node_id
|
||||
};
|
||||
|
||||
const auto &key_id
|
||||
|
|
|
@ -89,7 +89,7 @@ struct node
|
|||
void push(std::shared_ptr<unit>);
|
||||
|
||||
node(const string_view &origin)
|
||||
:id{"", origin}
|
||||
:id{m::node::id::origin, origin}
|
||||
,room{id}
|
||||
{}
|
||||
};
|
||||
|
|
|
@ -597,7 +597,7 @@ cache_set(const json::object &keys)
|
|||
|
||||
const m::node::id::buf node_id
|
||||
{
|
||||
"", server_name
|
||||
m::node::id::origin, server_name
|
||||
};
|
||||
|
||||
const m::node::room node_room
|
||||
|
@ -634,7 +634,7 @@ cache_get(const string_view &server_name,
|
|||
{
|
||||
const m::node::id::buf node_id
|
||||
{
|
||||
"", server_name
|
||||
m::node::id::origin, server_name
|
||||
};
|
||||
|
||||
const m::node::room node_room
|
||||
|
|
Loading…
Add table
Reference in a new issue