mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 16:33:53 +01:00
ircd:Ⓜ️:room: Expose bootstrap to interface.
This commit is contained in:
parent
1f1b3033f9
commit
8e0ac58987
3 changed files with 73 additions and 23 deletions
|
@ -174,6 +174,10 @@ struct ircd::m::room
|
|||
static event::idx index(const id &, std::nothrow_t);
|
||||
static event::idx index(const id &);
|
||||
|
||||
static void bootstrap(const event &, const string_view &host);
|
||||
static void bootstrap(const event::id &, const string_view &host);
|
||||
static event::id::buf bootstrap(const id &, const id::user &, const string_view &host);
|
||||
|
||||
static size_t purge(const room &); // cuidado!
|
||||
};
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ ircd::m::join(const room &room,
|
|||
if(!exists(room))
|
||||
{
|
||||
const auto &room_id(room.room_id);
|
||||
return bootstrap(room_id.host(), room_id, user_id); //TODO: host
|
||||
return bootstrap(room_id, user_id, room_id.host()); //TODO: host
|
||||
}
|
||||
|
||||
json::iov event;
|
||||
|
@ -121,7 +121,7 @@ ircd::m::join(const m::room::alias &room_alias,
|
|||
};
|
||||
|
||||
if(!exists(room_id))
|
||||
return bootstrap(room_alias.host(), room_id, user_id);
|
||||
return bootstrap(room_id, user_id, room_alias.host());
|
||||
|
||||
const m::room room
|
||||
{
|
||||
|
@ -160,10 +160,6 @@ bootstrap_backfill(const string_view &host,
|
|||
const m::room::id &,
|
||||
const m::event::id &);
|
||||
|
||||
static void
|
||||
bootstrap_worker(const string_view &host,
|
||||
const m::event::id &);
|
||||
|
||||
conf::item<seconds>
|
||||
make_join_timeout
|
||||
{
|
||||
|
@ -236,9 +232,10 @@ lazychain_enable
|
|||
};
|
||||
|
||||
event::id::buf
|
||||
bootstrap(std::string host,
|
||||
const m::room::id &room_id,
|
||||
const m::user::id &user_id)
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::bootstrap(const m::room::id &room_id,
|
||||
const m::user::id &user_id,
|
||||
const string_view &host)
|
||||
{
|
||||
log::debug
|
||||
{
|
||||
|
@ -253,27 +250,49 @@ bootstrap(std::string host,
|
|||
bootstrap_make_join(host, room_id, user_id)
|
||||
};
|
||||
|
||||
context
|
||||
{
|
||||
"joinstrap", 128_KiB,
|
||||
context::POST | context::DETACH,
|
||||
[host(std::move(host)), event_id(std::string(event_id))]
|
||||
{
|
||||
bootstrap_worker(host, event_id);
|
||||
}
|
||||
};
|
||||
bootstrap(event_id, host); // asynchronous; returns quickly
|
||||
|
||||
return event_id;
|
||||
}
|
||||
|
||||
void
|
||||
bootstrap_worker(const string_view &host,
|
||||
const m::event::id &event_id)
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::bootstrap(const m::event::id &event_id,
|
||||
const string_view &host)
|
||||
try
|
||||
{
|
||||
const m::event::fetch event
|
||||
const m::event::fetch event{event_id};
|
||||
assert(event.source);
|
||||
context
|
||||
{
|
||||
event_id
|
||||
"joinstrap", 128_KiB,
|
||||
context::POST | context::DETACH,
|
||||
[host(std::string(host)), event(std::string(event.source))]
|
||||
{
|
||||
bootstrap(m::event{event}, host);
|
||||
}
|
||||
};
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
log::error
|
||||
{
|
||||
m::log, "join bootstrap for %s to %s :%s",
|
||||
string_view{event_id},
|
||||
string(host),
|
||||
e.what()
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::room::bootstrap(const m::event &event,
|
||||
const string_view &host)
|
||||
try
|
||||
{
|
||||
const m::event::id &event_id
|
||||
{
|
||||
at<"event_id"_>(event)
|
||||
};
|
||||
|
||||
const m::room::id &room_id
|
||||
|
@ -347,7 +366,7 @@ catch(const std::exception &e)
|
|||
log::error
|
||||
{
|
||||
m::log, "join bootstrap for %s to %s :%s",
|
||||
string_view{event_id},
|
||||
string_view{at<"event_id"_>(event)},
|
||||
string(host),
|
||||
e.what()
|
||||
};
|
||||
|
|
|
@ -9835,6 +9835,33 @@ console_cmd__room__stats(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__restrap(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"event_id", "host"
|
||||
}};
|
||||
|
||||
const m::event::id &event_id
|
||||
{
|
||||
param.at("event_id")
|
||||
};
|
||||
|
||||
const net::hostport &host_
|
||||
{
|
||||
param.at("host")
|
||||
};
|
||||
|
||||
const string_view &host
|
||||
{
|
||||
param.at("host")
|
||||
};
|
||||
|
||||
m::room::bootstrap(event_id, host);
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// user
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue