feat: add flag to redactEvent with edits#2389
Conversation
af153c0 to
4097e9d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2389 +/- ##
==========================================
- Coverage 59.29% 59.21% -0.09%
==========================================
Files 161 162 +1
Lines 20300 20330 +30
==========================================
+ Hits 12037 12038 +1
- Misses 8263 8292 +29
Continue to review full report in Codecov by Harness.
|
4097e9d to
0964378
Compare
PR SummaryMedium Risk Overview When The MSC3912 extension is exported from Reviewed by Cursor Bugbot for commit e261e44. Bugbot is set up for automated code reviews on this repo. Configure here. |
0964378 to
e261e44
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Edit fetch ignores pagination tokens
- Manual edit redaction now paginates related m.replace events with from/nextBatch until all pages are processed.
- ✅ Fixed: Main redact lacks rate retry
- The primary event redaction now uses the same retryAfterMs rate-limit retry path as edit redactions.
Or push these changes by commenting:
@cursor push ed4d881c74
Preview (ed4d881c74)
diff --git a/lib/src/room.dart b/lib/src/room.dart
--- a/lib/src/room.dart
+++ b/lib/src/room.dart
@@ -2491,24 +2491,47 @@
);
}
- final edits = await client.getRelatingEventsWithRelType(
- id,
- eventId,
- RelationshipTypes.edit,
- );
- for (final edit in edits.chunk) {
- final txnid = client.generateUniqueTransactionId();
+ Future<String?> redactWithRateLimitRetry(
+ String redactionEventId,
+ String txid,
+ ) async {
try {
- await client.redactEvent(id, edit.eventId, txnid, reason: reason);
+ return await client.redactEvent(
+ id,
+ redactionEventId,
+ txid,
+ reason: reason,
+ );
} on MatrixException catch (e) {
final retryAfterMs = e.retryAfterMs;
if (retryAfterMs == null) rethrow;
await Future.delayed(Duration(milliseconds: retryAfterMs));
- await client.redactEvent(id, edit.eventId, txnid, reason: reason);
+ return await client.redactEvent(
+ id,
+ redactionEventId,
+ txid,
+ reason: reason,
+ );
}
}
- return await client.redactEvent(id, eventId, messageID, reason: reason);
+ String? nextBatch;
+ do {
+ final edits = await client.getRelatingEventsWithRelType(
+ id,
+ eventId,
+ RelationshipTypes.edit,
+ from: nextBatch,
+ limit: 50,
+ );
+ for (final edit in edits.chunk) {
+ final txnid = client.generateUniqueTransactionId();
+ await redactWithRateLimitRetry(edit.eventId, txnid);
+ }
+ nextBatch = edits.nextBatch;
+ } while (nextBatch != null);
+
+ return await redactWithRateLimitRetry(eventId, messageID);
}
/// This tells the server that the user is typing for the next N millisecondsYou can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit e261e44. Configure here.


closes https://famedly.atlassian.net/browse/FM-732