0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 06:28:55 +02:00

ircd:Ⓜ️:device: Add has(user, device_id, property) overload to interface suite.

This commit is contained in:
Jason Volk 2019-03-09 18:48:32 -08:00
parent d8da7814e8
commit 1381524f95
3 changed files with 32 additions and 0 deletions

View file

@ -124,6 +124,7 @@ struct ircd::m::device
static bool for_each(const user &, const string_view &id, const closure_bool &); // each property
static bool get(std::nothrow_t, const user &, const string_view &id, const string_view &prop, const closure &);
static bool get(const user &, const string_view &id, const string_view &prop, const closure &);
static bool has(const user &, const string_view &id, const string_view &prop);
static bool has(const user &, const string_view &id);
static bool del(const user &, const string_view &id);
static bool set(const user &, const string_view &id, const string_view &prop, const string_view &val);

View file

@ -1714,6 +1714,21 @@ ircd::m::device::has(const m::user &user,
return function(user, id);
}
bool
ircd::m::device::has(const m::user &user,
const string_view &id,
const string_view &prop)
{
using prototype = bool (const m::user &, const string_view &id, const string_view &prop);
static mods::import<prototype> function
{
"m_device", "ircd::m::device::has"
};
return function(user, id, prop);
}
bool
ircd::m::device::get(const m::user &user,
const string_view &id,

View file

@ -174,6 +174,22 @@ ircd::m::device::has(const m::user &user,
return ret;
}
bool
IRCD_MODULE_EXPORT
ircd::m::device::has(const m::user &user,
const string_view &id,
const string_view &prop)
{
bool ret{false};
get(std::nothrow, user, id, prop, [&ret]
(const string_view &value)
{
ret = !empty(value);
});
return ret;
}
bool
IRCD_MODULE_EXPORT
ircd::m::device::get(std::nothrow_t,