mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:Ⓜ️ Add origins::has() to query if origin is in room.
This commit is contained in:
parent
8b5d27d1fc
commit
59531912e4
2 changed files with 37 additions and 0 deletions
|
@ -279,6 +279,7 @@ struct ircd::m::room::origins
|
||||||
bool _test_(const closure_bool &view) const;
|
bool _test_(const closure_bool &view) const;
|
||||||
bool test(const closure_bool &view) const;
|
bool test(const closure_bool &view) const;
|
||||||
void for_each(const closure &view) const;
|
void for_each(const closure &view) const;
|
||||||
|
bool has(const string_view &origin) const;
|
||||||
size_t count() const;
|
size_t count() const;
|
||||||
|
|
||||||
origins(const m::room &room)
|
origins(const m::room &room)
|
||||||
|
|
|
@ -867,6 +867,42 @@ const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ircd::m::room::origins::has(const string_view &origin)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
db::index &index
|
||||||
|
{
|
||||||
|
dbs::room_origins
|
||||||
|
};
|
||||||
|
|
||||||
|
char querybuf[512];
|
||||||
|
const auto query
|
||||||
|
{
|
||||||
|
dbs::room_origins_key(querybuf, room.room_id, origin)
|
||||||
|
};
|
||||||
|
|
||||||
|
auto it
|
||||||
|
{
|
||||||
|
index.begin(query)
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!it)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const string_view &key
|
||||||
|
{
|
||||||
|
lstrip(it->first, "\0"_sv)
|
||||||
|
};
|
||||||
|
|
||||||
|
const string_view &key_origin
|
||||||
|
{
|
||||||
|
std::get<0>(dbs::room_origins_key(key))
|
||||||
|
};
|
||||||
|
|
||||||
|
return key_origin == origin;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ircd::m::room::origins::for_each(const closure &view)
|
ircd::m::room::origins::for_each(const closure &view)
|
||||||
const
|
const
|
||||||
|
|
Loading…
Reference in a new issue