mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-18 05:41:56 +01:00
Deletes all events in maximum chunks of 200 elements to avoid the 65KB stringified JSON limit of many relays.
This commit is contained in:
parent
27d2e2309a
commit
89638ff261
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user