#1520 Fixed event context resolving for the callback query that is coming from the business account

This commit is contained in:
JRoot Junior 2024-06-22 02:41:50 +03:00
parent 3baa7383c1
commit c446b28d8b
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2

View file

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