mirror of
https://github.com/matrix-construct/construct
synced 2024-10-04 06:38:58 +02:00
ircd:Ⓜ️🪝 Add a set to track all hooks for a site.
This commit is contained in:
parent
63e662606a
commit
523bf19f30
2 changed files with 17 additions and 0 deletions
|
@ -60,6 +60,7 @@ struct ircd::m::hook::site
|
|||
std::multimap<string_view, hook *> sender;
|
||||
std::multimap<string_view, hook *> state_key;
|
||||
std::multimap<string_view, hook *> type;
|
||||
std::set<hook *> hooks;
|
||||
|
||||
friend class hook;
|
||||
bool add(hook &);
|
||||
|
|
16
ircd/m/m.cc
16
ircd/m/m.cc
|
@ -2540,6 +2540,16 @@ catch(const std::exception &e)
|
|||
bool
|
||||
ircd::m::hook::site::add(hook &hook)
|
||||
{
|
||||
if(!hooks.emplace(&hook).second)
|
||||
{
|
||||
log::warning
|
||||
{
|
||||
"Hook %p already registered to site %s", &hook, name()
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(json::get<"origin"_>(hook.matching))
|
||||
origin.emplace(at<"origin"_>(hook.matching), &hook);
|
||||
|
||||
|
@ -2589,6 +2599,12 @@ ircd::m::hook::site::del(hook &hook)
|
|||
if(json::get<"type"_>(hook.matching))
|
||||
unmap(type, at<"type"_>(hook.matching));
|
||||
|
||||
const auto erased
|
||||
{
|
||||
hooks.erase(&hook)
|
||||
};
|
||||
|
||||
assert(erased);
|
||||
--count;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue