mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
modules/m_room: Add util to force event into present state w/ console cmd.
This commit is contained in:
parent
b4e7bb062c
commit
c352822d94
2 changed files with 62 additions and 0 deletions
|
@ -4498,6 +4498,39 @@ console_cmd__room__state(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__state__force(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"event_id"
|
||||
}};
|
||||
|
||||
const m::event::id &event_id
|
||||
{
|
||||
param.at(0)
|
||||
};
|
||||
|
||||
const m::event::fetch event
|
||||
{
|
||||
event_id
|
||||
};
|
||||
|
||||
using prototype = bool (const m::event &);
|
||||
static m::import<prototype> state__force_present
|
||||
{
|
||||
"m_room", "state__force_present"
|
||||
};
|
||||
|
||||
const auto res
|
||||
{
|
||||
state__force_present(event)
|
||||
};
|
||||
|
||||
out << "forced " << event_id << " into present state" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__room__state__rebuild__present(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
|
@ -185,6 +185,35 @@ is_complete(const m::room &room)
|
|||
return {true, depth};
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
state__force_present(const m::event &event)
|
||||
{
|
||||
db::txn txn
|
||||
{
|
||||
*m::dbs::events
|
||||
};
|
||||
|
||||
if(!defined(json::get<"state_key"_>(event)))
|
||||
throw error
|
||||
{
|
||||
"event %s is not a state event (no state_key)",
|
||||
json::get<"event_id"_>(event)
|
||||
};
|
||||
|
||||
m::dbs::write_opts opts;
|
||||
opts.event_idx = index(event);
|
||||
opts.present = true;
|
||||
opts.history = false;
|
||||
opts.head = false;
|
||||
opts.refs = false;
|
||||
|
||||
m::dbs::_index__room_state(txn, event, opts);
|
||||
m::dbs::_index__room_joined(txn, event, opts);
|
||||
|
||||
txn();
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" size_t
|
||||
state__rebuild_present(const m::room &room)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue