From 678806749d013b151afa2ac328cf7efb569ee1fc Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 1 Jul 2022 10:24:12 +0200 Subject: Add a /command to redact all visible messages sent by a user --- src/timeline/TimelineModel.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/timeline/TimelineModel.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 3fe4c07f..ad0a8c11 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -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 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>(*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) { -- cgit 1.5.1