diff --git a/include/ircd/m/room/state.h b/include/ircd/m/room/state.h index a8bc7dfec..aeacac149 100644 --- a/include/ircd/m/room/state.h +++ b/include/ircd/m/room/state.h @@ -39,8 +39,10 @@ struct ircd::m::room::state const event::fetch::opts *fopts {nullptr}; mutable bool _not_present {false}; // cached result of !present() + // Check if this object is representing the present state or a past state. bool present() const; + // Iterate the state bool for_each(const types_bool &) const; void for_each(const types &) const; bool for_each(const string_view &type, const keys_bool &view) const; @@ -77,10 +79,8 @@ struct ircd::m::room::state void get(const string_view &type, const string_view &state_key, const event::closure_idx &) const; void get(const string_view &type, const string_view &state_key, const event::id::closure &) const; void get(const string_view &type, const string_view &state_key, const event::closure &) const; - - // Fetch and return state event id - event::id::buf get(std::nothrow_t, const string_view &type, const string_view &state_key = "") const; - event::id::buf get(const string_view &type, const string_view &state_key = "") const; + event::idx get(std::nothrow_t, const string_view &type, const string_view &state_key = "") const; + event::idx get(const string_view &type, const string_view &state_key = "") const; // Initiate a database prefetch on the state to cache for future access. size_t prefetch(const string_view &type, const event::idx &start = 0, const event::idx &stop = 0) const; diff --git a/ircd/m_room.cc b/ircd/m_room.cc index c0aef91ac..dbd8a35e6 100644 --- a/ircd/m_room.cc +++ b/ircd/m_room.cc @@ -893,32 +893,32 @@ ircd::m::room::state::state(const m::room &room, { } -ircd::m::event::id::buf +ircd::m::event::idx ircd::m::room::state::get(const string_view &type, const string_view &state_key) const { - event::id::buf ret; - get(type, state_key, event::id::closure{[&ret] - (const event::id &event_id) + event::idx ret; + get(type, state_key, event::closure_idx{[&ret] + (const event::idx &event_idx) { - ret = event_id; + ret = event_idx; }}); return ret; } -ircd::m::event::id::buf +ircd::m::event::idx ircd::m::room::state::get(std::nothrow_t, const string_view &type, const string_view &state_key) const { - event::id::buf ret; - get(std::nothrow, type, state_key, event::id::closure{[&ret] - (const event::id &event_id) + event::idx ret{0}; + get(std::nothrow, type, state_key, event::closure_idx{[&ret] + (const event::idx &event_idx) { - ret = event_id; + ret = event_idx; }}); return ret; diff --git a/modules/federation/make_join.cc b/modules/federation/make_join.cc index ce3cea541..7aefc6857 100644 --- a/modules/federation/make_join.cc +++ b/modules/federation/make_join.cc @@ -86,17 +86,22 @@ get__make_join(client &client, room_id }; - auto auth_event_id + auto auth_event_idx { state.get(std::nothrow, "m.room.member", user_id) }; - if(!auth_event_id) - auth_event_id = state.get("m.room.create"); + if(!auth_event_idx) + auth_event_idx = state.get("m.room.create"); + + const auto auth_event_id + { + m::event_id(auth_event_idx) + }; const m::event::fetch aevf { - auth_event_id, std::nothrow + auth_event_idx, std::nothrow }; const json::value auth[] diff --git a/modules/m_room.cc b/modules/m_room.cc index 83d535b22..ade7bff3a 100644 --- a/modules/m_room.cc +++ b/modules/m_room.cc @@ -319,14 +319,14 @@ is_complete(const m::room &room) room }; - const auto create_id + const auto create_idx { state.get("m.room.create") }; room::messages it { - room, create_id, &fopts + room, create_idx, &fopts }; int64_t depth(-1); @@ -386,7 +386,7 @@ state__rebuild_present(const m::room &room) room }; - const auto create_id + const auto create_idx { state.get("m.room.create") }; @@ -398,7 +398,7 @@ state__rebuild_present(const m::room &room) m::room::messages it { - room, create_id, &fopts + room, create_idx, &fopts }; if(!it) @@ -440,7 +440,7 @@ state__rebuild_history(const m::room &room) room }; - const auto create_id + const auto create_idx { state.get("m.room.create") }; @@ -452,7 +452,7 @@ state__rebuild_history(const m::room &room) m::room::messages it { - room, create_id, &fopts + room, create_idx, &fopts }; if(!it) @@ -607,7 +607,7 @@ head__rebuild(const m::room &room) { size_t ret{0}; const m::room::state state{room}; - const auto create_id + const auto create_idx { state.get("m.room.create") }; @@ -619,7 +619,7 @@ head__rebuild(const m::room &room) m::room::messages it { - room, create_id, &fopts + room, create_idx, &fopts }; if(!it)