0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

modules/console: Add redactfill command.

This commit is contained in:
Jason Volk 2020-11-19 17:01:17 -08:00
parent a67e2a6671
commit ebe958d574

View file

@ -11928,6 +11928,60 @@ console_cmd__room__power__revoke(opt &out, const string_view &line)
return true;
}
bool
console_cmd__room__redactfill(opt &out, const string_view &line)
{
const params param{line, " ",
{
"room_id", "count", "sender", "reason"
}};
const auto room_id
{
m::room_id(param.at("room_id"))
};
size_t count
{
param.at("count", 0UL)
};
const auto sender
{
param["sender"]?
m::user::id{param["sender"]}:
m::me()
};
const auto reason
{
param.at("reason", "redactfill"_sv)
};
m::room::events it
{
room_id, -1UL
};
while(it && count > 0)
{
const auto event_id
{
m::event_id(it.event_idx())
};
const auto redact_id
{
m::redact(room_id, sender, event_id, reason)
};
--count;
--it;
}
return true;
}
bool
console_id__room(opt &out,
const m::room::id &id,