fix: improve logging and pagination logic in delete_old_messages function

This commit is contained in:
2026-05-10 11:32:24 +02:00
parent 4eecfc4aff
commit c15e9bbd7c
+2 -8
View File
@@ -539,17 +539,11 @@ def delete_old_messages(minutes: int = 6) -> None:
headers, DISCORD_CHANNEL_ID, webhook_id, author_id, cutoff, last_message_id
)
# Exit loop if no more messages to delete
# Stop scanning when a page has no eligible messages to delete.
# Continuing pagination here can walk indefinitely through history.
if not delete_list:
if deleted_count == 0:
if next_last_message_id is None or next_last_message_id == last_message_id:
logging.info("No messages to delete.")
break
else:
logging.info(
"No messages deleted in this batch, but more messages may exist... Continuing pagination.")
last_message_id = next_last_message_id
continue
else:
logging.info("No more messages to delete.")
break