mirror of
https://github.com/matrix-construct/construct
synced 2024-11-13 21:41:06 +01:00
ircd:Ⓜ️:room: Reenable the has state query; apply state::get(nothrow) in places.
This commit is contained in:
parent
cf18cdfcb7
commit
366716c890
1 changed files with 20 additions and 10 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue