Skip to content

Commit

Permalink
feat: data saturation for Forward entity
Browse files Browse the repository at this point in the history
  • Loading branch information
kutuzov13 committed Apr 10, 2024
1 parent 6b27924 commit 0fbb72f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pybotx/models/message/forward.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
from dataclasses import dataclass
from datetime import datetime
from typing import Literal
from uuid import UUID

from pybotx.models.api_base import VerifiedPayloadBaseModel
from pybotx.models.enums import BotAPIEntityTypes
from pybotx.models.enums import BotAPIEntityTypes, ChatTypes, APIChatTypes


@dataclass
class Forward:
chat_id: UUID
author_id: UUID
sync_id: UUID
forward_type: ChatTypes
chat_name: str
inserted_at: datetime


class BotAPIForwardData(VerifiedPayloadBaseModel):
group_chat_id: UUID
forward_type: APIChatTypes
sender_huid: UUID
source_sync_id: UUID
source_chat_name: str
source_inserted_at: datetime


class BotAPIForward(VerifiedPayloadBaseModel):
Expand Down
5 changes: 4 additions & 1 deletion pybotx/models/message/incoming_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
BotAPIMentionTypes,
ClientPlatforms,
convert_chat_type_to_domain,
convert_client_platform_to_domain,
convert_client_platform_to_domain, APIChatTypes,
)
from pybotx.models.message.forward import BotAPIForward, Forward
from pybotx.models.message.mentions import (
Expand Down Expand Up @@ -162,8 +162,11 @@ def convert_bot_api_entity_to_domain(api_entity: BotAPIEntity) -> Entity:

return Forward(
chat_id=api_entity.data.group_chat_id,
forward_type=convert_chat_type_to_domain(api_entity.data.forward_type),
author_id=api_entity.data.sender_huid,
sync_id=api_entity.data.source_sync_id,
chat_name=api_entity.data.source_chat_name,
inserted_at=api_entity.data.source_inserted_at,
)

if api_entity.type == BotAPIEntityTypes.REPLY:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_incoming_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ async def default_handler(message: IncomingMessage, bot: Bot) -> None:
),
forward=Forward(
chat_id=UUID("918da23a-1c9a-506e-8a6f-1328f1499ee8"),
chat_name="Simple Chat",
forward_type=ChatTypes.PERSONAL_CHAT,
inserted_at=datetime_formatter("2020-04-21T22:09:32.178Z"),
author_id=UUID("c06a96fa-7881-0bb6-0e0b-0af72fe3683f"),
sync_id=UUID("a7ffba12-8d0a-534e-8896-a0aa2d93a434"),
),
Expand Down

0 comments on commit 0fbb72f

Please sign in to comment.