mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 07:20:55 +01:00
ircd:Ⓜ️:device: Reduce/reuse codepath to set property to value.
This commit is contained in:
parent
9ac34573e5
commit
135798c8ab
1 changed files with 2 additions and 12 deletions
|
@ -50,28 +50,18 @@ bool
|
|||
ircd::m::device::set(const m::user &user,
|
||||
const device &device)
|
||||
{
|
||||
const user::room user_room{user};
|
||||
const string_view &device_id
|
||||
{
|
||||
json::at<"device_id"_>(device)
|
||||
};
|
||||
|
||||
json::for_each(device, [&user, &user_room, &device_id]
|
||||
json::for_each(device, [&user, &device_id]
|
||||
(const auto &prop, auto &&val)
|
||||
{
|
||||
if(!json::defined(json::value(val)))
|
||||
return;
|
||||
|
||||
char buf[m::event::TYPE_MAX_SIZE];
|
||||
const string_view type{fmt::sprintf
|
||||
{
|
||||
buf, "ircd.device.%s", prop
|
||||
}};
|
||||
|
||||
m::send(user_room, user, type, device_id, json::members
|
||||
{
|
||||
{ "", val }
|
||||
});
|
||||
set(user, device_id, prop, val);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue