From 7e677f4f973f2eca7e67c442edbca44c07179397 Mon Sep 17 00:00:00 2001 From: codl Date: Sat, 2 Sep 2017 20:00:44 +0200 Subject: [PATCH] whoops. move actions taken on unreachable accs to the celery task it's not each service lib's job to deal with this --- lib/mastodon.py | 2 -- lib/twitter.py | 4 ---- tasks.py | 5 +++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/mastodon.py b/lib/mastodon.py index c8c6d79..99ee15d 100644 --- a/lib/mastodon.py +++ b/lib/mastodon.py @@ -90,8 +90,6 @@ def get_api_for_acc(account): continue return api - account.force_log_out() - def fetch_acc(acc, cursor=None): api = get_api_for_acc(acc) diff --git a/lib/twitter.py b/lib/twitter.py index aaa8d27..4819f34 100644 --- a/lib/twitter.py +++ b/lib/twitter.py @@ -89,10 +89,6 @@ def get_twitter_for_acc(account): # temporary error, re-raise raise e - # if no tokens are valid, we log out the user so we'll get a fresh - # token when they log in again - account.policy_enabled = False - account.force_log_out() return None diff --git a/tasks.py b/tasks.py index 2d5ff23..c41eee9 100644 --- a/tasks.py +++ b/tasks.py @@ -135,13 +135,14 @@ def periodic_cleanup(): .filter(OAuthToken.account_id == None) # noqa: E711 .delete(synchronize_session=False)) - # disable users with no tokens + # disable and log out users with no tokens unreachable = ( Account.query .outerjoin(Account.tokens) .group_by(Account).having(db.func.count(OAuthToken.token) == 0) .filter(Account.policy_enabled == True)) # noqa: E712 for account in unreachable: + account.force_log_out() account.policy_enabled = False account.reason = """ Your account was disabled because Forget no longer had access to @@ -262,7 +263,7 @@ def refresh_account_with_longest_time_since_refresh(): refresh_account(acc.id) -app.add_periodic_task(6*60, periodic_cleanup) +app.add_periodic_task(120, periodic_cleanup) app.add_periodic_task(40, queue_fetch_for_most_stale_accounts) app.add_periodic_task(15, queue_deletes) app.add_periodic_task(60, refresh_account_with_oldest_post)