Add break condition in cleanup script

This commit is contained in:
lluni 2023-08-01 19:18:49 +02:00
parent c48ca60623
commit f9b720e2e1
Signed by: lluni
GPG key ID: ACEEB468BC325D35

View file

@ -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