0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-12 13:01:07 +01:00

ircd:Ⓜ️🆔 Support intuitive constructions of m::node::id.

This commit is contained in:
Jason Volk 2018-09-30 17:47:41 -07:00
parent 4f3f729d9b
commit da8beda0c3
8 changed files with 45 additions and 26 deletions

View file

@ -92,8 +92,8 @@ enum ircd::m::id::sigil
ROOM = '!', ///< Room ID (4.2.2) ROOM = '!', ///< Room ID (4.2.2)
ROOM_ALIAS = '#', ///< Room alias (4.2.3) ROOM_ALIAS = '#', ///< Room alias (4.2.3)
GROUP = '+', ///< Group ID (experimental) GROUP = '+', ///< Group ID (experimental)
NODE = ':', ///< Node ID (experimental)
DEVICE = '%', ///< Device ID (experimental) DEVICE = '%', ///< Device ID (experimental)
NODE = ':', ///< Node ID (experimental)
}; };
/// (Appendix 4.2.1) User Identifiers /// (Appendix 4.2.1) User Identifiers
@ -205,21 +205,6 @@ struct ircd::m::id::group
group() = default; 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) /// Device ID (EXPERIMENTAL)
/// ///
struct ircd::m::id::device struct ircd::m::id::device
@ -235,6 +220,30 @@ struct ircd::m::id::device
device() = default; 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 // Utilities
namespace ircd::m namespace ircd::m
{ {

View file

@ -735,7 +735,7 @@ try
{ {
const m::node::id::buf node_id const m::node::id::buf node_id
{ {
"", origin m::node::id::origin, origin
}; };
const m::node node const m::node node

View file

@ -330,7 +330,7 @@ ircd::m::my_room
ircd::m::node::id::buf ircd::m::node::id::buf
ircd_node_id ircd_node_id
{ {
"", "localhost" // replaced after conf init ircd::m::node::id::origin, "localhost" // replaced after conf init
}; };
ircd::m::node ircd::m::node
@ -370,7 +370,7 @@ ircd::m::self::init::init(const string_view &origin)
ircd_room_id = {"ircd", origin}; ircd_room_id = {"ircd", origin};
m::my_room = {ircd_room_id}; m::my_room = {ircd_room_id};
ircd_node_id = {"", origin}; ircd_node_id = {node::id::origin, origin};
m::my_node = {ircd_node_id}; m::my_node = {ircd_node_id};
users_room_id = {"users", origin}; users_room_id = {"users", origin};

View file

@ -181,7 +181,7 @@ const
const m::node::id::buf node_id const m::node::id::buf node_id
{ {
"", unquote(at<"origin"_>(*this)) m::node::id::origin, unquote(at<"origin"_>(*this))
}; };
const m::node node const m::node node

View file

@ -267,7 +267,7 @@ try
"The X-Matrix Authorization is invalid." "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; request.origin = x_matrix.origin;
// If we have an error cached from previously not being able to // If we have an error cached from previously not being able to

View file

@ -6948,9 +6948,14 @@ console_cmd__node__keys(opt &out, const string_view &line)
"node_id", "[limit]" "node_id", "[limit]"
}}; }};
const m::node::id::buf node_id
{
m::node::id::origin, param.at(0)
};
const m::node &node const m::node &node
{ {
param.at(0) node_id
}; };
auto limit auto limit
@ -6983,9 +6988,14 @@ console_cmd__node__key(opt &out, const string_view &line)
"node_id", "key_id" "node_id", "key_id"
}}; }};
const m::node::id::buf node_id
{
m::node::id::origin, param.at(0)
};
const m::node &node const m::node &node
{ {
param.at(0) node_id
}; };
const auto &key_id const auto &key_id

View file

@ -89,7 +89,7 @@ struct node
void push(std::shared_ptr<unit>); void push(std::shared_ptr<unit>);
node(const string_view &origin) node(const string_view &origin)
:id{"", origin} :id{m::node::id::origin, origin}
,room{id} ,room{id}
{} {}
}; };

View file

@ -597,7 +597,7 @@ cache_set(const json::object &keys)
const m::node::id::buf node_id const m::node::id::buf node_id
{ {
"", server_name m::node::id::origin, server_name
}; };
const m::node::room node_room const m::node::room node_room
@ -634,7 +634,7 @@ cache_get(const string_view &server_name,
{ {
const m::node::id::buf node_id const m::node::id::buf node_id
{ {
"", server_name m::node::id::origin, server_name
}; };
const m::node::room node_room const m::node::room node_room