diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-11-08 19:32:14 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-11-08 19:32:14 +0100 |
commit | c4c13a1da9d477dde4f52b1ff9b8327cfef55f9d (patch) | |
tree | cc544a0532c0ce19f63a6cc2324363ae90ec0314 /src/timeline/TimelineModel.cpp | |
parent | Fix bootstrap after registration (diff) | |
download | nheko-c4c13a1da9d477dde4f52b1ff9b8327cfef55f9d.tar.xz |
Fix redaction of edited messages
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r-- | src/timeline/TimelineModel.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 0e5ce510..aa7a68f3 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -344,6 +344,19 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj [](const QString &msg) { emit ChatPage::instance()->showNotification(msg); }, Qt::QueuedConnection); + connect(this, &TimelineModel::dataAtIdChanged, this, [this](QString id) { + relatedEventCacheBuster++; + + auto idx = idToIndex(id); + if (idx != -1) { + auto pos = index(idx); + nhlog::ui()->debug("data changed at {}", id.toStdString()); + emit dataChanged(pos, pos); + } else { + nhlog::ui()->debug("id not found {}", id.toStdString()); + } + }); + connect(this, &TimelineModel::newMessageToSend, this, @@ -1095,7 +1108,8 @@ TimelineModel::showReadReceipts(QString id) void TimelineModel::redactEvent(QString id) { - if (!id.isEmpty()) + if (!id.isEmpty()) { + auto edits = events.edits(id.toStdString()); http::client()->redact_event( room_id_.toStdString(), id.toStdString(), @@ -1106,8 +1120,26 @@ TimelineModel::redactEvent(QString id) return; } - emit eventRedacted(id); + emit dataAtIdChanged(id); }); + + // redact all edits to prevent leaks + for (const auto &e : edits) { + auto id_ = mtx::accessors::event_id(e); + http::client()->redact_event( + room_id_.toStdString(), + id_, + [this, id, id_](const mtx::responses::EventId &, mtx::http::RequestErr err) { + if (err) { + emit redactionFailed(tr("Message redaction failed: %1") + .arg(QString::fromStdString(err->matrix_error.error))); + return; + } + + emit dataAtIdChanged(id); + }); + } + } } int |