From 770cd0ec5eb556d912bd9d200b2da76c7e3bd7c8 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Thu, 23 Feb 2023 00:13:47 -0800 Subject: bot: fix login flow --- dbstore/peewee_store.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'dbstore') diff --git a/dbstore/peewee_store.py b/dbstore/peewee_store.py index 89e4b4b..3d37140 100644 --- a/dbstore/peewee_store.py +++ b/dbstore/peewee_store.py @@ -24,6 +24,23 @@ class User(BaseModel): toot_visibility = CharField(max_length=128, default=TOOT_VISIBILITY_PRIVATE) +def get_user_by_state(state: str) -> dict: + with db.connection_context(): + try: + user = User.get(User.state == state) + return { + "telegram_user_id": user.telegram_user_id, + "access_key": user.access_key, + "home_instance": user.home_instance, + "state": user.state, + "client_id": user.client_id, + "client_secret": user.client_secret, + "toot_visibility": user.toot_visibility, + } + except DoesNotExist: + return {} + + class Location(BaseModel): fsq_id = CharField(unique=True, primary_key=True) name = CharField(max_length=128) -- cgit v1.2.3