mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
modules/client/pushrules: Insert rule_id to rule on upload rather than outputs.
This commit is contained in:
parent
f20bdbceb8
commit
02430413ef
2 changed files with 5 additions and 39 deletions
|
@ -131,28 +131,9 @@ ircd::m::push::handle_get(client &client,
|
|||
};
|
||||
|
||||
const auto append_rule{[]
|
||||
(json::stack::array &_kind, const auto &path, const json::object &rule)
|
||||
(json::stack::array &array, const auto &path, const json::object &rule)
|
||||
{
|
||||
const auto &[scope, kind, ruleid]
|
||||
{
|
||||
path
|
||||
};
|
||||
|
||||
json::stack::object object
|
||||
{
|
||||
_kind
|
||||
};
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
object, "rule_id", ruleid
|
||||
};
|
||||
|
||||
for(const auto &[key, val] : rule)
|
||||
json::stack::member
|
||||
{
|
||||
object, key, val
|
||||
};
|
||||
array.append(rule);
|
||||
}};
|
||||
|
||||
if(ruleid)
|
||||
|
@ -343,6 +324,7 @@ ircd::m::push::handle_put(client &client,
|
|||
{
|
||||
{ "enabled", rule.get("enabled", true) },
|
||||
{ "default", false },
|
||||
{ "rule_id", ruleid },
|
||||
})
|
||||
};
|
||||
|
||||
|
|
|
@ -176,25 +176,9 @@ ircd::m::sync::push_rules(data &data)
|
|||
};
|
||||
|
||||
pushrules.for_each(push::path{scope, kind, {}}, [&_kind]
|
||||
(const auto &event_idx, const auto &path, const auto &members)
|
||||
(const auto &event_idx, const auto &path, const json::object &rule)
|
||||
{
|
||||
const auto &[scope, kind, ruleid] {path};
|
||||
json::stack::object object
|
||||
{
|
||||
_kind
|
||||
};
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
object, "rule_id", ruleid
|
||||
};
|
||||
|
||||
for(const auto &[key, val] : members)
|
||||
json::stack::member
|
||||
{
|
||||
object, key, val
|
||||
};
|
||||
|
||||
_kind.append(rule);
|
||||
return true;
|
||||
});
|
||||
}};
|
||||
|
|
Loading…
Reference in a new issue