Add another return condition in cleanup script

This commit is contained in:
lluni 2023-08-02 19:29:36 +02:00
parent 70625e5f1b
commit 0a084946a3
Signed by: lluni
GPG key ID: ACEEB468BC325D35

View file

@ -26,6 +26,9 @@ def cleanup(limit: int = 40, id: int | None = None):
last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, limit=limit)
id_oldest_of_last_posts = -1
for _ in range(4):
# return if there are no posts to check
if len(last_posts) == 0:
return
id_oldest_of_last_posts = last_posts[-1]["id"]
last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, max_id=id_oldest_of_last_posts, limit=limit)
else: