mirror of
https://github.com/matrix-construct/construct
synced 2024-09-30 04:38:52 +02:00
modules/client/rooms: Add a state reindexer routine.
This commit is contained in:
parent
8f3b84fff9
commit
5590238b1f
1 changed files with 40 additions and 0 deletions
|
@ -215,3 +215,43 @@ state__iov(const room &room,
|
|||
|
||||
return commit(room, event, content);
|
||||
}
|
||||
|
||||
extern "C" size_t
|
||||
state__rebuild_present(const m::room &room)
|
||||
{
|
||||
size_t ret{0};
|
||||
const auto create_id
|
||||
{
|
||||
room::state{room}.get("m.room.create")
|
||||
};
|
||||
|
||||
room::messages it
|
||||
{
|
||||
room, create_id
|
||||
};
|
||||
|
||||
if(!it)
|
||||
return ret;
|
||||
|
||||
db::txn txn{*dbs::events};
|
||||
for(; it; ++it)
|
||||
{
|
||||
const event &event{*it};
|
||||
if(!defined(json::get<"state_key"_>(event)))
|
||||
continue;
|
||||
|
||||
dbs::write_opts opts;
|
||||
opts.idx = it.event_idx();
|
||||
opts.present = true;
|
||||
opts.history = false;
|
||||
opts.head = false;
|
||||
opts.refs = false;
|
||||
|
||||
dbs::_index__room_state(txn, event, opts);
|
||||
dbs::_index__room_joined(txn, event, opts);
|
||||
++ret;
|
||||
}
|
||||
|
||||
txn();
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue