mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 20:46:32 +02: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:
@@ -1149,13 +1149,14 @@ class Account(
|
|||||||
fun delete(notes: List<Note>) {
|
fun delete(notes: List<Note>) {
|
||||||
if (!isWriteable()) return
|
if (!isWriteable()) return
|
||||||
|
|
||||||
val myEvents = notes.filter { it.author == userProfile() }
|
val myNoteVersions = notes.filter { it.author == userProfile() }.mapNotNull { it.event as? Event }
|
||||||
val myNoteVersions = myEvents.mapNotNull { it.event as? Event }
|
|
||||||
|
|
||||||
if (myNoteVersions.isNotEmpty()) {
|
if (myNoteVersions.isNotEmpty()) {
|
||||||
DeletionEvent.create(myNoteVersions, signer) {
|
// chunks in 200 elements to avoid going over the 65KB limit for events.
|
||||||
Client.send(it)
|
myNoteVersions.chunked(200).forEach { chunkedList ->
|
||||||
LocalCache.justConsume(it, null)
|
DeletionEvent.create(chunkedList, signer) { deletionEvent ->
|
||||||
|
Client.send(deletionEvent)
|
||||||
|
LocalCache.justConsume(deletionEvent, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user