From 9a86b452683c52bef153d1737e75aa3f8f57f40e Mon Sep 17 00:00:00 2001 From: codl Date: Tue, 29 Aug 2017 17:50:19 +0200 Subject: [PATCH] fix twitter when all refreshed posts are gone --- tasks.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tasks.py b/tasks.py index 2e43595..abdaef3 100644 --- a/tasks.py +++ b/tasks.py @@ -186,11 +186,12 @@ def delete_from_account(account_id): if account.service == 'twitter': action = lib.twitter.delete posts = refresh_posts(posts) - eligible = random.choice(list( # nosec - (post for post in posts if - (not account.policy_keep_favourites or not post.favourite) - and (not account.policy_keep_media or not post.has_media) - ))) + if posts: + eligible = random.choice(list( # nosec + (post for post in posts if + (not account.policy_keep_favourites or not post.favourite) + and (not account.policy_keep_media or not post.has_media) + ))) elif account.service == 'mastodon': action = lib.mastodon.delete for post in posts: