0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-10 05:58:56 +02:00

ircd:Ⓜ️:room::bootstrap: Reuse any existing join event on bootstrap.

This commit is contained in:
Jason Volk 2019-09-15 18:14:06 -07:00
parent 8fe92eea9b
commit f9c47eee58

View file

@ -140,8 +140,23 @@ ircd::m::room::bootstrap::bootstrap(m::event::id::buf &event_id_buf,
host
};
// synchronous; yields ctx.
event_id_buf = m::bootstrap::make_join(host, room_id, user_id);
const auto member_event_idx
{
m::room(room_id).get(std::nothrow, "m.room.member", user_id)
};
const bool existing_join
{
member_event_idx &&
m::room::members::membership(member_event_idx, "join")
};
if(existing_join)
event_id_buf = m::event_id(member_event_idx, std::nothrow);
if(!event_id_buf)
event_id_buf = m::bootstrap::make_join(host, room_id, user_id);
assert(event_id_buf);
// asynchronous; returns quickly