whoops. move actions taken on unreachable accs to the celery task

it's not each service lib's job to deal with this
This commit is contained in:
codl 2017-09-02 20:00:44 +02:00
parent 73b7ee2a53
commit 7e677f4f97
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
3 changed files with 3 additions and 8 deletions

View File

@ -90,8 +90,6 @@ def get_api_for_acc(account):
continue continue
return api return api
account.force_log_out()
def fetch_acc(acc, cursor=None): def fetch_acc(acc, cursor=None):
api = get_api_for_acc(acc) api = get_api_for_acc(acc)

View File

@ -89,10 +89,6 @@ def get_twitter_for_acc(account):
# temporary error, re-raise # temporary error, re-raise
raise e 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 return None

View File

@ -135,13 +135,14 @@ def periodic_cleanup():
.filter(OAuthToken.account_id == None) # noqa: E711 .filter(OAuthToken.account_id == None) # noqa: E711
.delete(synchronize_session=False)) .delete(synchronize_session=False))
# disable users with no tokens # disable and log out users with no tokens
unreachable = ( unreachable = (
Account.query Account.query
.outerjoin(Account.tokens) .outerjoin(Account.tokens)
.group_by(Account).having(db.func.count(OAuthToken.token) == 0) .group_by(Account).having(db.func.count(OAuthToken.token) == 0)
.filter(Account.policy_enabled == True)) # noqa: E712 .filter(Account.policy_enabled == True)) # noqa: E712
for account in unreachable: for account in unreachable:
account.force_log_out()
account.policy_enabled = False account.policy_enabled = False
account.reason = """ account.reason = """
Your account was disabled because Forget no longer had access to 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) 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(40, queue_fetch_for_most_stale_accounts)
app.add_periodic_task(15, queue_deletes) app.add_periodic_task(15, queue_deletes)
app.add_periodic_task(60, refresh_account_with_oldest_post) app.add_periodic_task(60, refresh_account_with_oldest_post)