2018-03-05 17:53:48 +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.
|
|
|
|
|
2019-06-22 05:59:41 +02:00
|
|
|
namespace ircd::m
|
|
|
|
{
|
|
|
|
extern hookfn<vm::eval &> create_my_node_hook;
|
|
|
|
extern hookfn<vm::eval &> create_nodes_hook;
|
|
|
|
}
|
2018-03-05 17:53:48 +01:00
|
|
|
|
2019-06-22 05:59:41 +02:00
|
|
|
ircd::mapi::header
|
2018-03-05 17:53:48 +01:00
|
|
|
IRCD_MODULE
|
|
|
|
{
|
2018-03-17 07:48:05 +01:00
|
|
|
"Server Nodes"
|
2018-03-05 17:53:48 +01:00
|
|
|
};
|
|
|
|
|
2019-06-22 05:59:41 +02:00
|
|
|
decltype(ircd::m::create_my_node_hook)
|
|
|
|
ircd::m::create_my_node_hook
|
2018-03-05 17:53:48 +01:00
|
|
|
{
|
2019-06-22 05:59:41 +02:00
|
|
|
{
|
|
|
|
{ "_site", "vm.effect" },
|
|
|
|
{ "room_id", "!nodes" },
|
|
|
|
{ "type", "m.room.create" },
|
|
|
|
},
|
|
|
|
[](const m::event &, m::vm::eval &)
|
|
|
|
{
|
|
|
|
create(m::my_node.room_id(), m::me.user_id);
|
|
|
|
}
|
2018-03-05 17:53:48 +01:00
|
|
|
};
|
|
|
|
|
2019-06-22 05:59:41 +02:00
|
|
|
decltype(ircd::m::create_nodes_hook)
|
|
|
|
ircd::m::create_nodes_hook
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ "_site", "vm.effect" },
|
|
|
|
{ "room_id", "!ircd" },
|
|
|
|
{ "type", "m.room.create" },
|
|
|
|
},
|
|
|
|
[](const m::event &, m::vm::eval &)
|
|
|
|
{
|
|
|
|
create(m::nodes, m::me.user_id);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// node
|
|
|
|
//
|
|
|
|
|
|
|
|
ircd::m::node
|
|
|
|
IRCD_MODULE_EXPORT
|
|
|
|
ircd::m::create(const node &node,
|
|
|
|
const json::members &args)
|
2018-03-05 17:53:48 +01:00
|
|
|
{
|
2019-05-27 02:44:12 +02:00
|
|
|
assert(node.node_id);
|
2018-03-05 17:53:48 +01:00
|
|
|
const m::room::id::buf room_id
|
|
|
|
{
|
|
|
|
node.room_id()
|
|
|
|
};
|
|
|
|
|
|
|
|
//TODO: ABA
|
|
|
|
create(room_id, m::me.user_id);
|
2019-06-22 05:59:41 +02:00
|
|
|
send(nodes, m::me.user_id, "ircd.node", node.node_id, args);
|
2018-03-05 17:53:48 +01:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2019-06-22 05:59:41 +02:00
|
|
|
bool
|
|
|
|
IRCD_MODULE_EXPORT
|
|
|
|
ircd::m::exists(const node &node)
|
2018-03-05 17:53:48 +01:00
|
|
|
{
|
2019-06-22 05:59:41 +02:00
|
|
|
return nodes.has("ircd.node", node.node_id);
|
2018-03-05 17:53:48 +01:00
|
|
|
}
|
|
|
|
|
2019-06-22 05:59:41 +02:00
|
|
|
bool
|
|
|
|
IRCD_MODULE_EXPORT
|
|
|
|
ircd::m::my(const node &node)
|
2018-03-05 17:53:48 +01:00
|
|
|
{
|
2019-06-22 05:59:41 +02:00
|
|
|
return my_host(node.node_id);
|
2018-03-05 17:53:48 +01:00
|
|
|
}
|