Skip to content

Commit

Permalink
feat: user_udid parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
nidemidovich committed Apr 5, 2023
1 parent e69e650 commit bd8a7bc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions pybotx/models/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions pybotx/models/message/incoming_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pybotx/models/system_events/smartapp_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def decorator(
if user_huid
else "f16cdc5f-6366-5552-9ecd-c36290ab3d11"
),
"user_udid": None,
"username": None,
},
"proto_version": 4,
Expand Down Expand Up @@ -215,6 +216,7 @@ def decorator(
metadata={},
sender=UserSender(
huid=uuid4(),
udid=None,
ad_login=ad_login,
ad_domain=ad_domain,
username=None,
Expand Down
2 changes: 2 additions & 0 deletions tests/system_events/test_smartapp_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_incoming_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bd8a7bc

Please sign in to comment.