diff --git a/include/ircd/m/room/bootstrap.h b/include/ircd/m/room/bootstrap.h index de0337ca6..2fc526ae7 100644 --- a/include/ircd/m/room/bootstrap.h +++ b/include/ircd/m/room/bootstrap.h @@ -13,6 +13,8 @@ struct ircd::m::room::bootstrap { + static bool required(const id &); + // restrap: synchronous; send_join 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 = {}); // synchronous make_join, eval; asynchronous send_join - bootstrap(event::id::buf &, const room::id &, const m::id::user &, const string_view &host); - - static bool required(const id &); + bootstrap(event::id::buf &, const room::id &, const m::id::user &, const vector_view &hosts); }; diff --git a/include/ircd/m/room/room.h b/include/ircd/m/room/room.h index dbf1e869a..83dc15ac6 100644 --- a/include/ircd/m/room/room.h +++ b/include/ircd/m/room/room.h @@ -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); 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 &remotes = {}); event::id::buf join(const id::room_alias &, const id::user &); // [SET] Create new room diff --git a/matrix/room_bootstrap.cc b/matrix/room_bootstrap.cc index b6435e498..1756a275d 100644 --- a/matrix/room_bootstrap.cc +++ b/matrix/room_bootstrap.cc @@ -85,16 +85,8 @@ ircd::m::bootstrap::make_join_timeout ircd::m::room::bootstrap::bootstrap(m::event::id::buf &event_id_buf, const m::room::id &room_id, const m::user::id &user_id, - const string_view &host) + const vector_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 { 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) }; + //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) event_id_buf = m::event_id(std::nothrow, member_event_idx); diff --git a/matrix/room_join.cc b/matrix/room_join.cc index 19af2ee71..bdd9d1792 100644 --- a/matrix/room_join.cc +++ b/matrix/room_join.cc @@ -25,10 +25,18 @@ ircd::m::join(const room::alias &room_alias, if(room::bootstrap::required(room_id)) { + const auto &remote + { + room_alias.host() + }; + m::event::id::buf ret; m::room::bootstrap { - ret, room_id, user_id, room_alias.host() + ret, + room_id, + user_id, + { &remote, 1 }, }; return ret; @@ -44,7 +52,8 @@ ircd::m::join(const room::alias &room_alias, ircd::m::event::id::buf ircd::m::join(const m::room &room, - const m::id::user &user_id) + const m::id::user &user_id, + const vector_view &remotes) { if(unlikely(!my(user_id))) throw panic @@ -61,7 +70,10 @@ ircd::m::join(const m::room &room, m::event::id::buf ret; m::room::bootstrap { - ret, room.room_id, user_id, room.room_id.host() //TODO: host + ret, + room.room_id, + user_id, + remotes, }; return ret;