From 60a41ce3ca88118f9c2e305282f651b935bdafd2 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Sun, 24 Sep 2023 13:07:16 +1300 Subject: [PATCH] Fix: Delete all messages matching search when more than 1000 results --- storage/search.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/search.go b/storage/search.go index c4398f7..3020130 100644 --- a/storage/search.go +++ b/storage/search.go @@ -124,7 +124,7 @@ func DeleteSearch(search string) error { if len(ids) > 0 { total := len(ids) - // split ids into chunks + // split ids into chunks of 1000 ids var chunks [][]string if total > 1000 { chunkSize := 1000 @@ -132,6 +132,10 @@ func DeleteSearch(search string) error { for chunkSize < len(ids) { ids, chunks = ids[chunkSize:], append(chunks, ids[0:chunkSize:chunkSize]) } + if len(ids) > 0 { + // add remaining ids <= 1000 + chunks = append(chunks, ids) + } } else { chunks = append(chunks, ids) }