ircd:Ⓜ️:room::bootstrap: Adjust interface allowing for multiple remote server arguments.

This commit is contained in:
Jason Volk 2020-04-21 17:58:32 -07:00
parent 912bcd3a3c
commit 538a2dab5c
4 changed files with 39 additions and 16 deletions

View File

@ -13,6 +13,8 @@
struct ircd::m::room::bootstrap struct ircd::m::room::bootstrap
{ {
static bool required(const id &);
// restrap: synchronous; send_join // restrap: synchronous; send_join
bootstrap(const event &, const string_view &host, const string_view &room_version = {}); bootstrap(const event &, const string_view &host, const string_view &room_version = {});
@ -20,7 +22,5 @@ struct ircd::m::room::bootstrap
bootstrap(const event::id &, const string_view &host, const string_view &room_version = {}); bootstrap(const event::id &, const string_view &host, const string_view &room_version = {});
// synchronous make_join, eval; asynchronous send_join // synchronous make_join, eval; asynchronous send_join
bootstrap(event::id::buf &, const room::id &, const m::id::user &, const string_view &host); bootstrap(event::id::buf &, const room::id &, const m::id::user &, const vector_view<const string_view> &hosts);
static bool required(const id &);
}; };

View File

@ -83,7 +83,7 @@ namespace ircd::m
event::id::buf invite(const room &, const id::user &target, const id::user &sender, json::iov &add_content); event::id::buf invite(const room &, const id::user &target, const id::user &sender, json::iov &add_content);
event::id::buf invite(const room &, const id::user &target, const id::user &sender); event::id::buf invite(const room &, const id::user &target, const id::user &sender);
event::id::buf leave(const room &, const id::user &); event::id::buf leave(const room &, const id::user &);
event::id::buf join(const room &, const id::user &); event::id::buf join(const room &, const id::user &, const vector_view<const string_view> &remotes = {});
event::id::buf join(const id::room_alias &, const id::user &); event::id::buf join(const id::room_alias &, const id::user &);
// [SET] Create new room // [SET] Create new room

View File

@ -85,16 +85,8 @@ ircd::m::bootstrap::make_join_timeout
ircd::m::room::bootstrap::bootstrap(m::event::id::buf &event_id_buf, ircd::m::room::bootstrap::bootstrap(m::event::id::buf &event_id_buf,
const m::room::id &room_id, const m::room::id &room_id,
const m::user::id &user_id, const m::user::id &user_id,
const string_view &host) const vector_view<const string_view> &hosts)
{ {
log::info
{
log, "Starting in %s for %s to '%s'",
string_view{room_id},
string_view{user_id},
host
};
const auto member_event_idx const auto member_event_idx
{ {
m::room(room_id).get(std::nothrow, "m.room.member", user_id) m::room(room_id).get(std::nothrow, "m.room.member", user_id)
@ -111,6 +103,25 @@ ircd::m::room::bootstrap::bootstrap(m::event::id::buf &event_id_buf,
m::version(room_version_buf, room_id, std::nothrow) m::version(room_version_buf, room_id, std::nothrow)
}; };
//TODO: try more hosts?
const auto &host
{
hosts.empty()?
room_id.host():
hosts[0]
};
log::info
{
log, "Starting in %s for %s to '%s' joined:%b ver:%s",
string_view{room_id},
string_view{user_id},
host,
existing_join,
room_version,
};
if(existing_join) if(existing_join)
event_id_buf = m::event_id(std::nothrow, member_event_idx); event_id_buf = m::event_id(std::nothrow, member_event_idx);

View File

@ -25,10 +25,18 @@ ircd::m::join(const room::alias &room_alias,
if(room::bootstrap::required(room_id)) if(room::bootstrap::required(room_id))
{ {
const auto &remote
{
room_alias.host()
};
m::event::id::buf ret; m::event::id::buf ret;
m::room::bootstrap m::room::bootstrap
{ {
ret, room_id, user_id, room_alias.host() ret,
room_id,
user_id,
{ &remote, 1 },
}; };
return ret; return ret;
@ -44,7 +52,8 @@ ircd::m::join(const room::alias &room_alias,
ircd::m::event::id::buf ircd::m::event::id::buf
ircd::m::join(const m::room &room, ircd::m::join(const m::room &room,
const m::id::user &user_id) const m::id::user &user_id,
const vector_view<const string_view> &remotes)
{ {
if(unlikely(!my(user_id))) if(unlikely(!my(user_id)))
throw panic throw panic
@ -61,7 +70,10 @@ ircd::m::join(const m::room &room,
m::event::id::buf ret; m::event::id::buf ret;
m::room::bootstrap m::room::bootstrap
{ {
ret, room.room_id, user_id, room.room_id.host() //TODO: host ret,
room.room_id,
user_id,
remotes,
}; };
return ret; return ret;