Skip to content

Commit

Permalink
Deletes all events in maximum chunks of 200 elements to avoid the 65K…
Browse files Browse the repository at this point in the history
…B stringified JSON limit of many relays.
  • Loading branch information
vitorpamplona committed Aug 9, 2024
1 parent 27d2e23 commit 89638ff
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1149,13 +1149,14 @@ class Account(
fun delete(notes: List<Note>) {
if (!isWriteable()) return

val myEvents = notes.filter { it.author == userProfile() }
val myNoteVersions = myEvents.mapNotNull { it.event as? Event }

val myNoteVersions = notes.filter { it.author == userProfile() }.mapNotNull { it.event as? Event }
if (myNoteVersions.isNotEmpty()) {
DeletionEvent.create(myNoteVersions, signer) {
Client.send(it)
LocalCache.justConsume(it, null)
// chunks in 200 elements to avoid going over the 65KB limit for events.
myNoteVersions.chunked(200).forEach { chunkedList ->
DeletionEvent.create(chunkedList, signer) { deletionEvent ->
Client.send(deletionEvent)
LocalCache.justConsume(deletionEvent, null)
}
}
}
}
Expand Down

0 comments on commit 89638ff

Please sign in to comment.