mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 09:40:12 +01:00
ircd:Ⓜ️:room: Add index(room::id) convenience to get some integer rep for room.
This commit is contained in:
parent
7e11176ab7
commit
d36a6cd2b0
2 changed files with 39 additions and 0 deletions
|
@ -100,6 +100,10 @@ struct ircd::m::room
|
|||
{}
|
||||
|
||||
room() = default;
|
||||
|
||||
// Index of create event
|
||||
static event::idx index(const id &, std::nothrow_t);
|
||||
static event::idx index(const id &);
|
||||
};
|
||||
|
||||
inline ircd::m::room::operator
|
||||
|
|
|
@ -263,6 +263,41 @@ ircd::m::my(const room &room)
|
|||
// room
|
||||
//
|
||||
|
||||
/// A room index is just the event::idx of its create event.
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::index(const room::id &room_id)
|
||||
{
|
||||
const auto ret
|
||||
{
|
||||
index(room_id, std::nothrow)
|
||||
};
|
||||
|
||||
if(!ret)
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"No index for room %s", string_view{room_id}
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::index(const room::id &room_id,
|
||||
std::nothrow_t)
|
||||
{
|
||||
uint64_t depth{0};
|
||||
room::messages it
|
||||
{
|
||||
room_id, depth
|
||||
};
|
||||
|
||||
return it? it.event_idx() : 0;
|
||||
}
|
||||
|
||||
//
|
||||
// room::room
|
||||
//
|
||||
|
||||
/// Test of the join_rule of the room is the argument.
|
||||
bool
|
||||
ircd::m::room::join_rule(const string_view &rule)
|
||||
|
|
Loading…
Add table
Reference in a new issue