Merge remote-tracking branch 'origin/dev-3.x' into dev-3.x

This commit is contained in:
JRoot Junior 2024-07-06 20:48:36 +03:00
commit 648395c1a2
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
2 changed files with 12 additions and 5 deletions

1
CHANGES/1520.bugfix.rst Normal file
View file

@ -0,0 +1 @@
Fixed event context resolving for the callback query that is coming from the business account

View file

@ -80,14 +80,20 @@ class UserContextMiddleware(BaseMiddleware):
if event.chosen_inline_result: if event.chosen_inline_result:
return EventContext(user=event.chosen_inline_result.from_user) return EventContext(user=event.chosen_inline_result.from_user)
if event.callback_query: if event.callback_query:
if event.callback_query.message: callback_query_message = event.callback_query.message
if callback_query_message:
return EventContext( return EventContext(
chat=event.callback_query.message.chat, chat=callback_query_message.chat,
user=event.callback_query.from_user, user=event.callback_query.from_user,
thread_id=( thread_id=(
event.callback_query.message.message_thread_id callback_query_message.message_thread_id
if not isinstance(event.callback_query.message, InaccessibleMessage) if not isinstance(callback_query_message, InaccessibleMessage)
and event.callback_query.message.is_topic_message and callback_query_message.is_topic_message
else None
),
business_connection_id=(
callback_query_message.business_connection_id
if not isinstance(callback_query_message, InaccessibleMessage)
else None else None
), ),
) )