mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd:Ⓜ️:user::pushrules: Add event_idx of rule as argument to closures.
ircd:Ⓜ️:user::pushers: Add event_idx of rule as argument to closures.
This commit is contained in:
parent
503db45a64
commit
ab4b31bc13
9 changed files with 26 additions and 25 deletions
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
struct ircd::m::user::pushers
|
struct ircd::m::user::pushers
|
||||||
{
|
{
|
||||||
using closure_bool = std::function<bool (const string_view &, const json::object &)>;
|
using closure_bool = std::function<bool (const event::idx &, const string_view &, const json::object &)>;
|
||||||
using closure = std::function<void (const string_view &, const json::object &)>;
|
using closure = std::function<void (const event::idx &, const string_view &, const json::object &)>;
|
||||||
|
|
||||||
m::user user;
|
m::user user;
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
struct ircd::m::user::pushrules
|
struct ircd::m::user::pushrules
|
||||||
{
|
{
|
||||||
using path = push::path;
|
using path = push::path;
|
||||||
using closure_bool = std::function<bool (const path &, const json::object &)>;
|
using closure_bool = std::function<bool (const event::idx &, const path &, const json::object &)>;
|
||||||
using closure = std::function<void (const path &, const json::object &)>;
|
using closure = std::function<void (const event::idx &, const path &, const json::object &)>;
|
||||||
|
|
||||||
m::user user;
|
m::user user;
|
||||||
|
|
||||||
|
|
|
@ -113,10 +113,10 @@ const
|
||||||
user_room.get(type, key)
|
user_room.get(type, key)
|
||||||
};
|
};
|
||||||
|
|
||||||
return m::get(std::nothrow, event_idx, "content", [&key, &closure]
|
return m::get(std::nothrow, event_idx, "content", [&key, &closure, &event_idx]
|
||||||
(const json::object &content)
|
(const json::object &content)
|
||||||
{
|
{
|
||||||
closure(key, content);
|
closure(event_idx, key, content);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,10 +143,10 @@ const
|
||||||
(const string_view &_type, const string_view &state_key, const m::event::idx &event_idx)
|
(const string_view &_type, const string_view &state_key, const m::event::idx &event_idx)
|
||||||
{
|
{
|
||||||
assert(type == _type);
|
assert(type == _type);
|
||||||
return m::query<bool>(std::nothrow, event_idx, "content", true, [&state_key, &closure]
|
return m::query<bool>(std::nothrow, event_idx, "content", true, [&]
|
||||||
(const json::object &content)
|
(const json::object &content)
|
||||||
{
|
{
|
||||||
return closure(state_key, content);
|
return closure(event_idx, state_key, content);
|
||||||
});
|
});
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ const
|
||||||
|
|
||||||
if(_ruleid == ruleid)
|
if(_ruleid == ruleid)
|
||||||
{
|
{
|
||||||
closure(path, rule);
|
closure(0UL, path, rule);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,10 +154,10 @@ const
|
||||||
user_room.get(std::nothrow, type, ruleid)
|
user_room.get(std::nothrow, type, ruleid)
|
||||||
};
|
};
|
||||||
|
|
||||||
return m::get(std::nothrow, event_idx, "content", [&path, &closure]
|
return m::get(std::nothrow, event_idx, "content", [&path, &closure, &event_idx]
|
||||||
(const json::object &content)
|
(const json::object &content)
|
||||||
{
|
{
|
||||||
closure(path, content);
|
closure(event_idx, path, content);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ const
|
||||||
"global", _kind, json::string{rule["rule_id"]}
|
"global", _kind, json::string{rule["rule_id"]}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!closure(path, rule))
|
if(!closure(0UL, path, rule))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,10 +232,10 @@ const
|
||||||
push::make_path(type, state_key)
|
push::make_path(type, state_key)
|
||||||
};
|
};
|
||||||
|
|
||||||
return m::query<bool>(std::nothrow, event_idx, "content", true, [&path, &closure]
|
return m::query<bool>(std::nothrow, event_idx, "content", true, [&]
|
||||||
(const json::object &content)
|
(const json::object &content)
|
||||||
{
|
{
|
||||||
return closure(path, content);
|
return closure(event_idx, path, content);
|
||||||
});
|
});
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ ircd::m::push::handle_pushers_get(client &client,
|
||||||
};
|
};
|
||||||
|
|
||||||
user_pushers.for_each([&pushers]
|
user_pushers.for_each([&pushers]
|
||||||
(const string_view &pushkey, const json::object &pusher)
|
(const event::idx &, const string_view &pushkey, const json::object &pusher)
|
||||||
{
|
{
|
||||||
pushers.append(pusher);
|
pushers.append(pusher);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -84,7 +84,7 @@ ircd::m::push::handle_get(client &client,
|
||||||
if(handle_enabled || handle_actions)
|
if(handle_enabled || handle_actions)
|
||||||
{
|
{
|
||||||
pushrules.get(path, [&]
|
pushrules.get(path, [&]
|
||||||
(const auto &path, const json::object &rule)
|
(const auto &event_idx, const auto &path, const json::object &rule)
|
||||||
{
|
{
|
||||||
const json::member member
|
const json::member member
|
||||||
{
|
{
|
||||||
|
@ -168,7 +168,7 @@ ircd::m::push::handle_get(client &client,
|
||||||
};
|
};
|
||||||
|
|
||||||
pushrules.get(std::nothrow, path, [&]
|
pushrules.get(std::nothrow, path, [&]
|
||||||
(const auto &path, const json::object &rule)
|
(const auto &event_idx, const auto &path, const json::object &rule)
|
||||||
{
|
{
|
||||||
append_rule(_kind, path, rule);
|
append_rule(_kind, path, rule);
|
||||||
});
|
});
|
||||||
|
@ -189,7 +189,7 @@ ircd::m::push::handle_get(client &client,
|
||||||
};
|
};
|
||||||
|
|
||||||
pushrules.for_each(push::path{scope, kind, {}}, [&]
|
pushrules.for_each(push::path{scope, kind, {}}, [&]
|
||||||
(const auto &path, const json::object &rule)
|
(const auto &event_idx, const auto &path, const json::object &rule)
|
||||||
{
|
{
|
||||||
append_rule(_kind, path, rule);
|
append_rule(_kind, path, rule);
|
||||||
return true;
|
return true;
|
||||||
|
@ -215,7 +215,7 @@ ircd::m::push::handle_get(client &client,
|
||||||
};
|
};
|
||||||
|
|
||||||
pushrules.for_each(push::path{scope, kind, {}}, [&]
|
pushrules.for_each(push::path{scope, kind, {}}, [&]
|
||||||
(const auto &path, const json::object &rule)
|
(const auto &event_idx, const auto &path, const json::object &rule)
|
||||||
{
|
{
|
||||||
append_rule(_kind, path, rule);
|
append_rule(_kind, path, rule);
|
||||||
return true;
|
return true;
|
||||||
|
@ -306,7 +306,7 @@ ircd::m::push::handle_put(client &client,
|
||||||
if(handle_enabled || handle_actions)
|
if(handle_enabled || handle_actions)
|
||||||
{
|
{
|
||||||
pushrules.get(path, [&]
|
pushrules.get(path, [&]
|
||||||
(const auto &path, const json::object &old_rule)
|
(const auto &event_idx, const auto &path, const json::object &old_rule)
|
||||||
{
|
{
|
||||||
const auto new_rule
|
const auto new_rule
|
||||||
{
|
{
|
||||||
|
|
|
@ -176,7 +176,7 @@ ircd::m::sync::push_rules(data &data)
|
||||||
};
|
};
|
||||||
|
|
||||||
pushrules.for_each(push::path{scope, kind, {}}, [&_kind]
|
pushrules.for_each(push::path{scope, kind, {}}, [&_kind]
|
||||||
(const auto &path, const json::object &members)
|
(const auto &event_idx, const auto &path, const auto &members)
|
||||||
{
|
{
|
||||||
const auto &[scope, kind, ruleid] {path};
|
const auto &[scope, kind, ruleid] {path};
|
||||||
json::stack::object object
|
json::stack::object object
|
||||||
|
|
|
@ -12033,7 +12033,7 @@ console_cmd__user__pushrules(opt &out, const string_view &line)
|
||||||
};
|
};
|
||||||
|
|
||||||
pushrules.for_each({scope, kind, ruleid}, [&out]
|
pushrules.for_each({scope, kind, ruleid}, [&out]
|
||||||
(const auto &path, const json::object &rule)
|
(const auto &event_idx, const auto &path, const json::object &rule)
|
||||||
{
|
{
|
||||||
const auto &[scope, kind, ruleid]
|
const auto &[scope, kind, ruleid]
|
||||||
{
|
{
|
||||||
|
@ -12041,6 +12041,7 @@ console_cmd__user__pushrules(opt &out, const string_view &line)
|
||||||
};
|
};
|
||||||
|
|
||||||
out
|
out
|
||||||
|
<< std::right << std::setw(10) << event_idx << " | "
|
||||||
<< std::left << std::setw(10) << scope << " | "
|
<< std::left << std::setw(10) << scope << " | "
|
||||||
<< std::left << std::setw(10) << kind << " | "
|
<< std::left << std::setw(10) << kind << " | "
|
||||||
<< std::left << std::setw(36) << ruleid << " "
|
<< std::left << std::setw(36) << ruleid << " "
|
||||||
|
@ -12078,7 +12079,7 @@ console_cmd__user__pushers(opt &out, const string_view &line)
|
||||||
if(pushkey)
|
if(pushkey)
|
||||||
{
|
{
|
||||||
pushers.get(pushkey, [&out]
|
pushers.get(pushkey, [&out]
|
||||||
(const auto &key, const json::object &pusher)
|
(const auto &event_idx, const auto &key, const json::object &pusher)
|
||||||
{
|
{
|
||||||
out
|
out
|
||||||
<< pusher
|
<< pusher
|
||||||
|
@ -12089,7 +12090,7 @@ console_cmd__user__pushers(opt &out, const string_view &line)
|
||||||
}
|
}
|
||||||
|
|
||||||
pushers.for_each([&out]
|
pushers.for_each([&out]
|
||||||
(const auto &pushkey, const json::object &pusher)
|
(const auto &event_idx, const auto &pushkey, const json::object &pusher)
|
||||||
{
|
{
|
||||||
out
|
out
|
||||||
<< std::left << std::setw(40) << pushkey << " | "
|
<< std::left << std::setw(40) << pushkey << " | "
|
||||||
|
|
|
@ -114,7 +114,7 @@ ircd::m::push::handle_kind(const event &event,
|
||||||
};
|
};
|
||||||
|
|
||||||
return pushrules.for_each(path, [&event, &eval, &user_id]
|
return pushrules.for_each(path, [&event, &eval, &user_id]
|
||||||
(const push::path &path, const push::rule &rule)
|
(const auto &event_idx, const auto &path, const auto &rule)
|
||||||
{
|
{
|
||||||
if(matching(event, eval, user_id, path, rule))
|
if(matching(event, eval, user_id, path, rule))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue