mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
modules/m_room: Add preliminary purge(); add linkage to console cmd.
This commit is contained in:
parent
23d0c7384d
commit
1552b56590
2 changed files with 45 additions and 0 deletions
|
@ -5292,6 +5292,23 @@ console_cmd__room__purge(opt &out, const string_view &line)
|
|||
m::room_id(token(line, ' ', 0))
|
||||
};
|
||||
|
||||
const m::room room
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
using prototype = size_t (const m::room &);
|
||||
static m::import<prototype> purge
|
||||
{
|
||||
"m_room", "purge"
|
||||
};
|
||||
|
||||
const size_t ret
|
||||
{
|
||||
purge(room)
|
||||
};
|
||||
|
||||
out << "erased " << ret << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,34 @@ IRCD_MODULE
|
|||
"Matrix state library; modular components."
|
||||
};
|
||||
|
||||
extern "C" size_t
|
||||
purge(const m::room &room)
|
||||
{
|
||||
size_t ret(0);
|
||||
db::txn txn
|
||||
{
|
||||
*m::dbs::events
|
||||
};
|
||||
|
||||
room.for_each([&txn, &ret]
|
||||
(const m::event::idx &idx)
|
||||
{
|
||||
const m::event::fetch event
|
||||
{
|
||||
idx
|
||||
};
|
||||
|
||||
m::dbs::write_opts opts;
|
||||
opts.op = db::op::DELETE;
|
||||
opts.event_idx = idx;
|
||||
m::dbs::write(txn, event, opts);
|
||||
++ret;
|
||||
});
|
||||
|
||||
txn();
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
make_auth(const m::room &room,
|
||||
json::stack::array &out,
|
||||
|
|
Loading…
Reference in a new issue