mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️:room::bootstrap: Move util to bootstrap::required().
This commit is contained in:
parent
b4a16c6678
commit
b979a20457
3 changed files with 25 additions and 28 deletions
|
@ -21,4 +21,6 @@ struct ircd::m::room::bootstrap
|
|||
|
||||
// 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 &);
|
||||
};
|
||||
|
|
|
@ -797,3 +797,24 @@ catch(const std::exception &e)
|
|||
// bootstrap process.
|
||||
throw;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::bootstrap::required(const id &room_id)
|
||||
{
|
||||
// No bootstrap for my rooms
|
||||
//TODO: issue for clustering
|
||||
if(my(room_id))
|
||||
return false;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
// copyright notice and this permission notice is present in all copies. The
|
||||
// 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::join(const room::alias &room_alias,
|
||||
const user::id &user_id)
|
||||
|
@ -28,7 +23,7 @@ ircd::m::join(const room::alias &room_alias,
|
|||
m::room_id(room_alias)
|
||||
};
|
||||
|
||||
if(need_bootstrap(room_id))
|
||||
if(room::bootstrap::required(room_id))
|
||||
{
|
||||
m::event::id::buf ret;
|
||||
m::room::bootstrap
|
||||
|
@ -58,7 +53,7 @@ ircd::m::join(const m::room &room,
|
|||
};
|
||||
|
||||
// Branch for when nothing is known about the room.
|
||||
if(need_bootstrap(room))
|
||||
if(room::bootstrap::required(room))
|
||||
{
|
||||
// The bootstrap condcts a blocking make_join and issues a join
|
||||
// event, returning the event_id; afterward asynchronously it will
|
||||
|
@ -140,24 +135,3 @@ ircd::m::join(const m::room &room,
|
|||
|
||||
return commit(room, event, content);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::need_bootstrap(const room::id &room_id)
|
||||
{
|
||||
// No bootstrap for my rooms
|
||||
//TODO: issue for clustering
|
||||
if(my(room_id))
|
||||
return false;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue