diff options
author | clarkzjw <[email protected]> | 2023-02-23 00:13:47 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 12:07:32 -0800 |
commit | 770cd0ec5eb556d912bd9d200b2da76c7e3bd7c8 (patch) | |
tree | 11cc26af821ea2b7e97c623aedfe51c487559f0e /dbstore/peewee_store.py | |
parent | 5402e3a2e9df24a883e2e20dfae6c92f11b8d499 (diff) | |
download | swarm2fediverse-770cd0ec5eb556d912bd9d200b2da76c7e3bd7c8.tar.gz |
bot: fix login flow
Diffstat (limited to 'dbstore/peewee_store.py')
-rw-r--r-- | dbstore/peewee_store.py | 17 |
1 files changed, 17 insertions, 0 deletions
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): | |||
24 | toot_visibility = CharField(max_length=128, default=TOOT_VISIBILITY_PRIVATE) | 24 | toot_visibility = CharField(max_length=128, default=TOOT_VISIBILITY_PRIVATE) |
25 | 25 | ||
26 | 26 | ||
27 | def get_user_by_state(state: str) -> dict: | ||
28 | with db.connection_context(): | ||
29 | try: | ||
30 | user = User.get(User.state == state) | ||
31 | return { | ||
32 | "telegram_user_id": user.telegram_user_id, | ||
33 | "access_key": user.access_key, | ||
34 | "home_instance": user.home_instance, | ||
35 | "state": user.state, | ||
36 | "client_id": user.client_id, | ||
37 | "client_secret": user.client_secret, | ||
38 | "toot_visibility": user.toot_visibility, | ||
39 | } | ||
40 | except DoesNotExist: | ||
41 | return {} | ||
42 | |||
43 | |||
27 | class Location(BaseModel): | 44 | class Location(BaseModel): |
28 | fsq_id = CharField(unique=True, primary_key=True) | 45 | fsq_id = CharField(unique=True, primary_key=True) |
29 | name = CharField(max_length=128) | 46 | name = CharField(max_length=128) |