mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
modules/conf: Add conf_updated(event_idx) overload handling errors on event::fetch.
This commit is contained in:
parent
2dd3b5b16a
commit
1011e2b9a3
1 changed files with 46 additions and 27 deletions
|
@ -81,10 +81,7 @@ get_conf_item(const string_view &key,
|
|||
{
|
||||
static const m::event::fetch::opts fopts
|
||||
{
|
||||
m::event::keys::include
|
||||
{
|
||||
"content"
|
||||
}
|
||||
m::event::keys::include { "content" }
|
||||
};
|
||||
|
||||
const m::room::state state
|
||||
|
@ -140,7 +137,8 @@ noexcept try
|
|||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
if(item_error_log) log::error
|
||||
if(item_error_log)
|
||||
log::error
|
||||
{
|
||||
"Failed to set conf item '%s' :%s",
|
||||
json::get<"state_key"_>(event),
|
||||
|
@ -148,6 +146,33 @@ catch(const std::exception &e)
|
|||
};
|
||||
}
|
||||
|
||||
static void
|
||||
conf_updated(const m::event::idx &event_idx)
|
||||
noexcept try
|
||||
{
|
||||
static const m::event::fetch::opts fopts
|
||||
{
|
||||
m::event::keys::include { "content", "state_key" }
|
||||
};
|
||||
|
||||
const m::event::fetch event
|
||||
{
|
||||
event_idx, fopts
|
||||
};
|
||||
|
||||
conf_updated(event);
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
if(item_error_log)
|
||||
log::error
|
||||
{
|
||||
"Failed to set conf item by event_idx:%lu :%s",
|
||||
event_idx,
|
||||
e.what()
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
handle_conf_updated(const m::event &event,
|
||||
m::vm::eval &)
|
||||
|
@ -171,10 +196,7 @@ init_conf_items()
|
|||
{
|
||||
static const m::event::fetch::opts fopts
|
||||
{
|
||||
m::event::keys::include
|
||||
{
|
||||
"content", "state_key"
|
||||
}
|
||||
m::event::keys::include { "content", "state_key" }
|
||||
};
|
||||
|
||||
const m::room::state state
|
||||
|
@ -184,33 +206,30 @@ init_conf_items()
|
|||
|
||||
state.prefetch("ircd.conf.item");
|
||||
state.for_each("ircd.conf.item", []
|
||||
(const m::event &event)
|
||||
(const auto &, const auto &state_key, const auto &event_idx)
|
||||
{
|
||||
conf_updated(event);
|
||||
conf_updated(event_idx);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
static void
|
||||
init_conf_item(conf::item<> &item)
|
||||
{
|
||||
static const m::event::fetch::opts fopts
|
||||
{
|
||||
m::event::keys::include
|
||||
{
|
||||
"content", "state_key"
|
||||
}
|
||||
};
|
||||
|
||||
const m::room::state state
|
||||
{
|
||||
conf_room, &fopts
|
||||
conf_room
|
||||
};
|
||||
|
||||
state.get(std::nothrow, "ircd.conf.item", item.name, []
|
||||
(const m::event &event)
|
||||
const auto &event_idx
|
||||
{
|
||||
conf_updated(event);
|
||||
});
|
||||
state.get(std::nothrow, "ircd.conf.item", item.name)
|
||||
};
|
||||
|
||||
if(!event_idx)
|
||||
return;
|
||||
|
||||
conf_updated(event_idx);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue