mirror of
https://github.com/matrix-construct/construct
synced 2025-01-15 17:16:49 +01:00
ircd:Ⓜ️:device: Add unrestricted set() overload.
This commit is contained in:
parent
55fd9505bc
commit
e3a6e55808
3 changed files with 39 additions and 0 deletions
|
@ -132,6 +132,7 @@ struct ircd::m::device
|
|||
static bool get(const user &, const string_view &id, const string_view &prop, const closure &);
|
||||
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);
|
||||
static bool set(const user &, const device &);
|
||||
|
||||
using super_type::tuple;
|
||||
|
|
16
ircd/m.cc
16
ircd/m.cc
|
@ -1621,6 +1621,22 @@ ircd::m::device::set(const m::user &user,
|
|||
return function(user, device_);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::device::set(const m::user &user,
|
||||
const string_view &id,
|
||||
const string_view &prop,
|
||||
const string_view &val)
|
||||
{
|
||||
using prototype = bool (const m::user &, const string_view &, const string_view &, const string_view &);
|
||||
|
||||
static mods::import<prototype> function
|
||||
{
|
||||
"m_device", "ircd::m::device::set"
|
||||
};
|
||||
|
||||
return function(user, id, prop, val);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::device::del(const m::user &user,
|
||||
const string_view &id)
|
||||
|
|
|
@ -52,6 +52,28 @@ ircd::m::device::set(const m::user &user,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::device::set(const m::user &user,
|
||||
const string_view &id,
|
||||
const string_view &prop,
|
||||
const string_view &val)
|
||||
{
|
||||
char buf[m::event::TYPE_MAX_SIZE];
|
||||
const string_view type{fmt::sprintf
|
||||
{
|
||||
buf, "ircd.device.%s", prop
|
||||
}};
|
||||
|
||||
const user::room user_room{user};
|
||||
m::send(user_room, user, type, id,
|
||||
{
|
||||
{ "", val }
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// To delete a device we iterate the user's room state for all types matching
|
||||
/// ircd.device.* (and ircd.device) which have a state_key of the device_id.
|
||||
/// Those events are redacted which removes them from appearing in the state.
|
||||
|
|
Loading…
Reference in a new issue