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 cc8d20e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pybotx/models/message/forward.py
@@ -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 APIChatTypes, BotAPIEntityTypes, ChatTypes


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


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


class BotAPIForward(VerifiedPayloadBaseModel):
Expand Down
3 changes: 3 additions & 0 deletions pybotx/models/message/incoming_message.py
Expand Up @@ -164,6 +164,9 @@ def convert_bot_api_entity_to_domain(api_entity: BotAPIEntity) -> Entity:
chat_id=api_entity.data.group_chat_id,
author_id=api_entity.data.sender_huid,
sync_id=api_entity.data.source_sync_id,
chat_name=api_entity.data.source_chat_name,
forward_type=convert_chat_type_to_domain(api_entity.data.forward_type),
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
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 cc8d20e

Please sign in to comment.