summary refs log tree commit diff
path: root/src/timeline/TimelineModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-07-01 10:24:12 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-07-01 10:24:12 +0200
commit678806749d013b151afa2ac328cf7efb569ee1fc (patch)
tree55f6cd4d6d02049040a2369b815ca93100c667de /src/timeline/TimelineModel.cpp
parentFix crash on empty user cache stored (diff)
downloadnheko-678806749d013b151afa2ac328cf7efb569ee1fc.tar.xz
Add a /command to redact all visible messages sent by a user
Diffstat (limited to '')
-rw-r--r--src/timeline/TimelineModel.cpp18
1 files changed, 18 insertions, 0 deletions
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
@@ -1272,6 +1272,24 @@ TimelineModel::showReadReceipts(QString id) } 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) { if (!id.isEmpty()) {