mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 06:51:08 +01:00
ircd:Ⓜ️:user::room_account_data: Expose type prefixing in interface.
This commit is contained in:
parent
8cc46765a3
commit
58a98806e9
2 changed files with 15 additions and 17 deletions
|
@ -227,6 +227,16 @@ struct ircd::m::user::room_account_data
|
|||
using closure_bool = std::function<bool (const string_view &key, const json::object &)>;
|
||||
using closure = std::function<void (const string_view &key, const json::object &)>;
|
||||
|
||||
static constexpr const string_view &type_prefix
|
||||
{
|
||||
"ircd.account_data"
|
||||
};
|
||||
|
||||
static constexpr const size_t &typebuf_size
|
||||
{
|
||||
m::room::id::MAX_SIZE + size(type_prefix)
|
||||
};
|
||||
|
||||
m::user user;
|
||||
m::room room;
|
||||
|
||||
|
|
|
@ -161,18 +161,6 @@ get__account_data(client &client,
|
|||
return {}; // responded from closure
|
||||
}
|
||||
|
||||
constexpr string_view
|
||||
room_account_data_type_prefix
|
||||
{
|
||||
"ircd.account_data"_sv
|
||||
};
|
||||
|
||||
constexpr size_t
|
||||
room_account_data_typebuf_size
|
||||
{
|
||||
m::room::id::MAX_SIZE + size(room_account_data_type_prefix)
|
||||
};
|
||||
|
||||
m::event::id::buf
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::user::room_account_data::set(const m::user &user,
|
||||
|
@ -180,7 +168,7 @@ ircd::m::user::room_account_data::set(const m::user &user,
|
|||
const string_view &user_type,
|
||||
const json::object &value)
|
||||
{
|
||||
char typebuf[room_account_data_typebuf_size];
|
||||
char typebuf[typebuf_size];
|
||||
const string_view type
|
||||
{
|
||||
_type(typebuf, room.room_id)
|
||||
|
@ -202,7 +190,7 @@ ircd::m::user::room_account_data::get(std::nothrow_t,
|
|||
const string_view &user_type,
|
||||
const closure &closure)
|
||||
{
|
||||
char typebuf[room_account_data_typebuf_size];
|
||||
char typebuf[typebuf_size];
|
||||
const string_view type
|
||||
{
|
||||
_type(typebuf, room.room_id)
|
||||
|
@ -228,7 +216,7 @@ ircd::m::user::room_account_data::for_each(const m::user &user,
|
|||
const m::room &room,
|
||||
const closure_bool &closure)
|
||||
{
|
||||
char typebuf[room_account_data_typebuf_size];
|
||||
char typebuf[typebuf_size];
|
||||
const string_view type
|
||||
{
|
||||
_type(typebuf, room.room_id)
|
||||
|
@ -267,10 +255,10 @@ IRCD_MODULE_EXPORT
|
|||
ircd::m::user::room_account_data::_type(const mutable_buffer &out,
|
||||
const m::room::id &room_id)
|
||||
{
|
||||
assert(size(out) >= room_account_data_typebuf_size);
|
||||
assert(size(out) >= typebuf_size);
|
||||
|
||||
string_view ret;
|
||||
ret = strlcpy(out, room_account_data_type_prefix);
|
||||
ret = strlcpy(out, type_prefix);
|
||||
ret = strlcat(out, room_id);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue