0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ircd:Ⓜ️:join: Unify condition for bootstrap; fix bootstrap on invite.

This commit is contained in:
Jason Volk 2020-04-16 15:45:07 -07:00
parent 7e44e524d2
commit 09ba5ee455

View file

@ -8,6 +8,11 @@
// copyright notice and this permission notice is present in all copies. The // copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file. // full license for this software is available in the LICENSE file.
namespace ircd::m
{
static bool need_bootstrap(const room::id &);
}
ircd::m::event::id::buf ircd::m::event::id::buf
ircd::m::join(const room::alias &room_alias, ircd::m::join(const room::alias &room_alias,
const user::id &user_id) const user::id &user_id)
@ -23,7 +28,7 @@ ircd::m::join(const room::alias &room_alias,
m::room_id(room_alias) m::room_id(room_alias)
}; };
if(!exists(room_id)) if(need_bootstrap(room_id))
{ {
m::event::id::buf ret; m::event::id::buf ret;
m::room::bootstrap m::room::bootstrap
@ -53,7 +58,7 @@ ircd::m::join(const m::room &room,
}; };
// Branch for when nothing is known about the room. // Branch for when nothing is known about the room.
if(!exists(room)) if(need_bootstrap(room))
{ {
// The bootstrap condcts a blocking make_join and issues a join // The bootstrap condcts a blocking make_join and issues a join
// event, returning the event_id; afterward asynchronously it will // event, returning the event_id; afterward asynchronously it will
@ -135,3 +140,19 @@ ircd::m::join(const m::room &room,
return commit(room, event, content); return commit(room, event, content);
} }
bool
ircd::m::need_bootstrap(const room::id &room_id)
{
// We have nothing for the room
if(!exists(room_id))
return true;
// No users are currently joined from this server;
//TODO: bootstrap shouldn't have to be used to re-sync a room where we have
//TODO: some partial state, so this condition should be eliminated.
if(local_joined(room_id) == 0)
return true;
return false;
}