From ce2d4defdecf376eca9f8579672779dfdf093d21 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 23 Sep 2022 15:47:11 +0200 Subject: Try to handle rate limiting --- src/timeline/TimelineModel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 1ddef7b7..36e21e53 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -1313,8 +1313,14 @@ TimelineModel::redactEvent(const QString &id, const QString &reason) http::client()->redact_event( room_id_.toStdString(), id.toStdString(), - [this, id](const mtx::responses::EventId &, mtx::http::RequestErr err) { + [this, id, reason](const mtx::responses::EventId &, mtx::http::RequestErr err) { if (err) { + if (err->status_code == 429 && err->matrix_error.retry_after.count() != 0) { + QTimer::singleShot(err->matrix_error.retry_after, this, [this, id, reason]() { + this->redactEvent(id, reason); + }); + return; + } emit redactionFailed(tr("Message redaction failed: %1") .arg(QString::fromStdString(err->matrix_error.error))); return; -- cgit 1.5.1