mirror of
https://github.com/matrix-construct/construct
synced 2024-06-10 05:58:56 +02:00
modules/console: Add wildcard for all devices to user devices update cmd.
This commit is contained in:
parent
faf796a56b
commit
b4b26484ec
|
@ -14457,9 +14457,9 @@ console_cmd__user__devices__update(opt &out, const string_view &line)
|
|||
param.at("user_id")
|
||||
};
|
||||
|
||||
const string_view &device_id
|
||||
const string_view &device_id_
|
||||
{
|
||||
param.at("device_id")
|
||||
param.at("device_id", "*"_sv)
|
||||
};
|
||||
|
||||
const bool deleted
|
||||
|
@ -14472,6 +14472,9 @@ console_cmd__user__devices__update(opt &out, const string_view &line)
|
|||
user_id
|
||||
};
|
||||
|
||||
const auto update{[&out, &user_id, &deleted]
|
||||
(const auto &device_id)
|
||||
{
|
||||
json::iov content;
|
||||
const json::iov::push push[]
|
||||
{
|
||||
|
@ -14485,7 +14488,30 @@ console_cmd__user__devices__update(opt &out, const string_view &line)
|
|||
m::user::devices::send(content)
|
||||
};
|
||||
|
||||
out << "done" << std::endl;
|
||||
out
|
||||
<< "broadcast:"
|
||||
<< broadcasted
|
||||
<< ' '
|
||||
<< device_id
|
||||
<< std::endl;
|
||||
}};
|
||||
|
||||
const bool found
|
||||
{
|
||||
!devices.for_each([&update, &device_id_]
|
||||
(const auto &, const string_view &device_id)
|
||||
{
|
||||
if(device_id_ != "*" && device_id != device_id_)
|
||||
return true;
|
||||
|
||||
update(device_id);
|
||||
return device_id != device_id_; // false to break
|
||||
})
|
||||
};
|
||||
|
||||
if(!found && deleted)
|
||||
update(device_id_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue