aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--callback.py3
-rw-r--r--dbstore/peewee_store.py17
2 files changed, 19 insertions, 1 deletions
diff --git a/callback.py b/callback.py
index 23b814b..d968523 100644
--- a/callback.py
+++ b/callback.py
@@ -97,10 +97,11 @@ async def callback_generate_fedi_login_url(update: Update, context: ContextTypes
97 scopes=BOT_SCOPE, 97 scopes=BOT_SCOPE,
98 state=state) 98 state=state)
99 99
100 await update.message.reply_text(PROMPT_FEDI_LOGIN, 100 msg = await update.message.reply_text(PROMPT_FEDI_LOGIN,
101 reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Login", url=oauth_url)]]), 101 reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Login", url=oauth_url)]]),
102 parse_mode=ParseMode.MARKDOWN) 102 parse_mode=ParseMode.MARKDOWN)
103 103
104 context.user_data[PROMPT_FEDI_LOGIN] = msg.message_id
104 return FEDI_LOGIN 105 return FEDI_LOGIN
105 106
106 107
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
27def 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
27class Location(BaseModel): 44class 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)
Powered by cgit v1.2.3 (git 2.41.0)