mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd:Ⓜ️:room: Add missing linear event::idx get().
This commit is contained in:
parent
dcffd35c40
commit
4947ef10f5
2 changed files with 38 additions and 0 deletions
|
@ -140,6 +140,8 @@ struct ircd::m::room
|
|||
bool has(const string_view &type) const;
|
||||
bool get(std::nothrow_t, const string_view &type, const event::closure &) const;
|
||||
void get(const string_view &type, const event::closure &) const;
|
||||
event::idx get(std::nothrow_t, const string_view &type) const;
|
||||
event::idx get(const string_view &type) const;
|
||||
|
||||
// misc / convenience utils
|
||||
bool membership(const m::id::user &, const string_view &membership = "join") const;
|
||||
|
|
|
@ -1368,6 +1368,42 @@ const
|
|||
return ret;
|
||||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::get(const string_view &type)
|
||||
const
|
||||
{
|
||||
const event::idx ret
|
||||
{
|
||||
get(std::nothrow, type)
|
||||
};
|
||||
|
||||
if(unlikely(!ret))
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"No events of type '%s' found in '%s'",
|
||||
type,
|
||||
room_id
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::get(std::nothrow_t,
|
||||
const string_view &type)
|
||||
const
|
||||
{
|
||||
event::idx ret{0};
|
||||
for_each(type, event::closure_idx_bool{[&ret]
|
||||
(const event::idx &event_idx)
|
||||
{
|
||||
ret = event_idx;
|
||||
return false;
|
||||
}});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::get(const string_view &type,
|
||||
const string_view &state_key)
|
||||
|
|
Loading…
Reference in a new issue