0
0
Fork 0
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:
Jason Volk 2019-03-01 12:57:04 -08:00
parent 8cc46765a3
commit 58a98806e9
2 changed files with 15 additions and 17 deletions

View file

@ -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_bool = std::function<bool (const string_view &key, const json::object &)>;
using closure = std::function<void (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::user user;
m::room room; m::room room;

View file

@ -161,18 +161,6 @@ get__account_data(client &client,
return {}; // responded from closure 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 m::event::id::buf
IRCD_MODULE_EXPORT IRCD_MODULE_EXPORT
ircd::m::user::room_account_data::set(const m::user &user, 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 string_view &user_type,
const json::object &value) const json::object &value)
{ {
char typebuf[room_account_data_typebuf_size]; char typebuf[typebuf_size];
const string_view type const string_view type
{ {
_type(typebuf, room.room_id) _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 string_view &user_type,
const closure &closure) const closure &closure)
{ {
char typebuf[room_account_data_typebuf_size]; char typebuf[typebuf_size];
const string_view type const string_view type
{ {
_type(typebuf, room.room_id) _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 m::room &room,
const closure_bool &closure) const closure_bool &closure)
{ {
char typebuf[room_account_data_typebuf_size]; char typebuf[typebuf_size];
const string_view type const string_view type
{ {
_type(typebuf, room.room_id) _type(typebuf, room.room_id)
@ -267,10 +255,10 @@ IRCD_MODULE_EXPORT
ircd::m::user::room_account_data::_type(const mutable_buffer &out, ircd::m::user::room_account_data::_type(const mutable_buffer &out,
const m::room::id &room_id) const m::room::id &room_id)
{ {
assert(size(out) >= room_account_data_typebuf_size); assert(size(out) >= typebuf_size);
string_view ret; string_view ret;
ret = strlcpy(out, room_account_data_type_prefix); ret = strlcpy(out, type_prefix);
ret = strlcat(out, room_id); ret = strlcat(out, room_id);
return ret; return ret;
} }