0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-12 13:01:07 +01:00

ircd:Ⓜ️:room: Reenable the has state query; apply state::get(nothrow) in places.

This commit is contained in:
Jason Volk 2018-02-09 11:57:19 -08:00
parent cf18cdfcb7
commit 366716c890

View file

@ -347,7 +347,8 @@ const
}; };
bool ret{false}; bool ret{false};
m::state::get(state_root, "m.room.member", user_id, [&membership, &ret] static const auto type{"m.room.member"};
m::state::get(std::nothrow, state_root, type, user_id, [&membership, &ret]
(const string_view &event_id) (const string_view &event_id)
{ {
event::fetch event; event::fetch event;
@ -458,16 +459,13 @@ const
dbs::state_root(state_root_buf, room_id, event_id) dbs::state_root(state_root_buf, room_id, event_id)
}; };
bool ret{false}; return m::state::get(std::nothrow, state_root, type, state_key, [&closure]
m::state::get(state_root, type, state_key, [&closure, &ret]
(const string_view &event_id) (const string_view &event_id)
{ {
event::fetch event; event::fetch event;
if(seek(event, event_id, std::nothrow)) if(seek(event, event_id, std::nothrow))
closure(event); closure(event);
}); });
return ret;
} }
bool bool
@ -485,14 +483,26 @@ ircd::m::room::has(const string_view &type,
const string_view &state_key) const string_view &state_key)
const const
{ {
const vm::query<vm::where::equal> query const event::id::buf event_id_buf
{ {
{ "room_id", room_id }, !event_id? head(room_id) : string_view{}
{ "type", type },
{ "state_key", state_key },
}; };
return m::vm::test(query); const event::id event_id
{
this->event_id? this->event_id : event_id_buf
};
m::state::id_buffer state_root_buf;
const auto state_root
{
dbs::state_root(state_root_buf, room_id, event_id)
};
return m::state::get(std::nothrow, state_root, type, state_key, []
(const string_view &event_id)
{
});
} }
void void