Add a /command to redact all visible messages sent by a user

This commit is contained in:
Nicolas Werner 2022-07-01 10:24:12 +02:00
parent 7198cee85e
commit 678806749d
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
4 changed files with 31 additions and 0 deletions

View file

@ -1271,6 +1271,24 @@ TimelineModel::showReadReceipts(QString id)
emit openReadReceiptsDialog(new ReadReceiptsProxy{id, roomId(), this});
}
void
TimelineModel::redactAllFromUser(const QString &userid, const QString &reason)
{
auto user = userid.toStdString();
std::vector<QString> toRedact;
for (auto it = events.size() - 1; it >= 0; --it) {
auto event = events.get(it, false);
if (event && mtx::accessors::sender(*event) == user &&
!std::holds_alternative<mtx::events::RoomEvent<mtx::events::msg::Redacted>>(*event)) {
toRedact.push_back(QString::fromStdString(mtx::accessors::event_id(*event)));
}
}
for (const auto &e : toRedact) {
redactEvent(e, reason);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}
void
TimelineModel::redactEvent(const QString &id, const QString &reason)
{