mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:Ⓜ️ Add room::get() passthru interface to room::state.
This commit is contained in:
parent
605fbe1859
commit
43d581f1e9
2 changed files with 20 additions and 32 deletions
|
@ -86,8 +86,11 @@ struct ircd::m::room
|
|||
|
||||
operator const id &() const { return room_id; }
|
||||
|
||||
// Convenience passthru to room::state (logarithmic query)
|
||||
bool get(std::nothrow_t, const string_view &type, const string_view &state_key, const event::closure &) const;
|
||||
void get(const string_view &type, const string_view &state_key, const event::closure &) const;
|
||||
|
||||
// X
|
||||
bool get(const event::closure &) const;
|
||||
void for_each(const event::closure &) const;
|
||||
|
||||
// misc
|
||||
|
|
|
@ -371,40 +371,25 @@ const
|
|||
while(++it);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::get(const event::closure &closure)
|
||||
const try
|
||||
void
|
||||
ircd::m::room::get(const string_view &type,
|
||||
const string_view &state_key,
|
||||
const event::closure &closure)
|
||||
const
|
||||
{
|
||||
auto it
|
||||
{
|
||||
dbs::room_events.begin(room_id)
|
||||
};
|
||||
|
||||
if(!it)
|
||||
return false;
|
||||
|
||||
const auto &key{it->first};
|
||||
const auto part
|
||||
{
|
||||
dbs::room_events_key(key)
|
||||
};
|
||||
|
||||
const auto event_id
|
||||
{
|
||||
std::get<1>(part)
|
||||
};
|
||||
|
||||
const event::fetch event
|
||||
{
|
||||
event_id
|
||||
};
|
||||
|
||||
closure(event);
|
||||
return true;
|
||||
const state state{*this};
|
||||
state.get(type, state_key, closure);
|
||||
}
|
||||
catch(const NOT_FOUND &)
|
||||
|
||||
bool
|
||||
ircd::m::room::get(std::nothrow_t,
|
||||
const string_view &type,
|
||||
const string_view &state_key,
|
||||
const event::closure &closure)
|
||||
const
|
||||
{
|
||||
return false;
|
||||
const state state{*this};
|
||||
return state.get(std::nothrow, type, state_key, closure);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue