diff --git a/cleanup.py b/cleanup.py index 43bca62..5778ac9 100644 --- a/cleanup.py +++ b/cleanup.py @@ -36,6 +36,10 @@ for i in range(5): # default: check 5 batches of 40 posts # get next batch of posts last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, max_id=id_oldest_of_last_posts, limit=40) + # break if there are no more posts + if len(last_posts) == 0: + break + # delete all old posts of the current batch for submission in last_posts: # if post has no favorites, boosts or replies, delete it