From bd8a7bc4b014edb54c9911b9784479d5f85e16d6 Mon Sep 17 00:00:00 2001 From: Nikita Demidovich Date: Tue, 4 Apr 2023 18:34:23 +0300 Subject: [PATCH] feat: user_udid parsing --- pybotx/models/base_command.py | 1 + pybotx/models/message/incoming_message.py | 2 ++ pybotx/models/system_events/smartapp_event.py | 1 + pyproject.toml | 2 +- tests/conftest.py | 2 ++ tests/system_events/test_smartapp_event.py | 2 ++ tests/test_incoming_message.py | 7 +++++++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pybotx/models/base_command.py b/pybotx/models/base_command.py index e16ed232..3ad82203 100644 --- a/pybotx/models/base_command.py +++ b/pybotx/models/base_command.py @@ -38,6 +38,7 @@ class BaseBotAPIContext(VerifiedPayloadBaseModel): class BotAPIUserContext(BaseBotAPIContext): user_huid: UUID + user_udid: Optional[UUID] ad_domain: Optional[str] ad_login: Optional[str] username: Optional[str] diff --git a/pybotx/models/message/incoming_message.py b/pybotx/models/message/incoming_message.py index f1b4a7c5..e9ba34bd 100644 --- a/pybotx/models/message/incoming_message.py +++ b/pybotx/models/message/incoming_message.py @@ -62,6 +62,7 @@ class UserDevice: @dataclass class UserSender: huid: UUID + udid: Optional[UUID] ad_login: Optional[str] ad_domain: Optional[str] username: Optional[str] @@ -225,6 +226,7 @@ def to_domain(self, raw_command: Dict[str, Any]) -> IncomingMessage: # noqa: WP sender = UserSender( huid=self.sender.user_huid, + udid=self.sender.user_udid, ad_login=self.sender.ad_login, ad_domain=self.sender.ad_domain, username=self.sender.username, diff --git a/pybotx/models/system_events/smartapp_event.py b/pybotx/models/system_events/smartapp_event.py index 0d834cc3..4bdcbbf2 100644 --- a/pybotx/models/system_events/smartapp_event.py +++ b/pybotx/models/system_events/smartapp_event.py @@ -95,6 +95,7 @@ def to_domain(self, raw_command: Dict[str, Any]) -> SmartAppEvent: sender = UserSender( huid=self.sender.user_huid, + udid=self.sender.user_udid, ad_login=self.sender.ad_login, ad_domain=self.sender.ad_domain, username=self.sender.username, diff --git a/pyproject.toml b/pyproject.toml index b02c13ae..3f613057 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pybotx" -version = "0.55.0" +version = "0.55.1" description = "A python library for interacting with eXpress BotX API" authors = [ "Sidnev Nikolay ", diff --git a/tests/conftest.py b/tests/conftest.py index 98dbd870..489db883 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -184,6 +184,7 @@ def decorator( if user_huid else "f16cdc5f-6366-5552-9ecd-c36290ab3d11" ), + "user_udid": None, "username": None, }, "proto_version": 4, @@ -215,6 +216,7 @@ def decorator( metadata={}, sender=UserSender( huid=uuid4(), + udid=None, ad_login=ad_login, ad_domain=ad_domain, username=None, diff --git a/tests/system_events/test_smartapp_event.py b/tests/system_events/test_smartapp_event.py index 3b9b8cb4..b39d141d 100644 --- a/tests/system_events/test_smartapp_event.py +++ b/tests/system_events/test_smartapp_event.py @@ -68,6 +68,7 @@ async def test__smartapp__succeed( "entities": [], "from": { "user_huid": "b9197d3a-d855-5d34-ba8a-eff3a975ab20", + "user_udid": None, "group_chat_id": "dea55ee4-7a9f-5da0-8c73-079f400ee517", "host": "cts.example.com", "ad_login": None, @@ -141,6 +142,7 @@ async def smartapp_handler(event: SmartAppEvent, bot: Bot) -> None: ), sender=UserSender( huid=UUID("b9197d3a-d855-5d34-ba8a-eff3a975ab20"), + udid=None, ad_login=None, ad_domain=None, username=None, diff --git a/tests/test_incoming_message.py b/tests/test_incoming_message.py index e0c45bf2..0886fba6 100644 --- a/tests/test_incoming_message.py +++ b/tests/test_incoming_message.py @@ -65,6 +65,7 @@ async def test__async_execute_raw_bot_command__minimally_filled_incoming_message "platform": None, "platform_package_id": None, "user_huid": "f16cdc5f-6366-5552-9ecd-c36290ab3d11", + "user_udid": None, "username": None, }, "proto_version": 4, @@ -99,6 +100,7 @@ async def default_handler(message: IncomingMessage, bot: Bot) -> None: metadata={}, sender=UserSender( huid=UUID("f16cdc5f-6366-5552-9ecd-c36290ab3d11"), + udid=None, ad_login=None, ad_domain=None, username=None, @@ -221,6 +223,7 @@ async def test__async_execute_raw_bot_command__maximum_filled_incoming_message( "platform": "web", "platform_package_id": "ru.unlimitedtech.express", "user_huid": "f16cdc5f-6366-5552-9ecd-c36290ab3d11", + "user_udid": "2f18d97b-201b-434d-ac1f-3c6d4b066117", "username": "Ivanov Ivan Ivanovich", }, "proto_version": 4, @@ -255,6 +258,7 @@ async def default_handler(message: IncomingMessage, bot: Bot) -> None: metadata={"message": "metadata"}, sender=UserSender( huid=UUID("f16cdc5f-6366-5552-9ecd-c36290ab3d11"), + udid=UUID("2f18d97b-201b-434d-ac1f-3c6d4b066117"), ad_login="login", ad_domain="domain", username="Ivanov Ivan Ivanovich", @@ -407,6 +411,7 @@ async def test__async_execute_raw_bot_command__all_mention_types( "platform": None, "platform_package_id": None, "user_huid": "f16cdc5f-6366-5552-9ecd-c36290ab3d11", + "user_udid": None, "username": None, }, "proto_version": 4, @@ -499,6 +504,7 @@ async def test__async_execute_raw_bot_command__unknown_entity_type( "platform": None, "platform_package_id": None, "user_huid": "f16cdc5f-6366-5552-9ecd-c36290ab3d11", + "user_udid": None, "username": None, }, "proto_version": 4, @@ -549,6 +555,7 @@ async def test__async_execute_raw_bot_command__unsupported_chat_type_accepted( "platform": None, "platform_package_id": None, "user_huid": "f16cdc5f-6366-5552-9ecd-c36290ab3d11", + "user_udid": None, "username": None, }, "proto_version": 4,