from typing import Optional, List, Any
from datetime import datetime

from ....core.interfaces.dto import Dto
from ....core.interfaces.core import Core
from ....core.interfaces.reaction import Reaction
from ....enums.conjoint.messages import MessageType


class Message[T: Any, Properties: Any](Core[Properties]):
  type: MessageType

  content: T

  caption: Optional[str]
  channel: Optional[str]  # Channel ID
  account: Optional[str]  # Account ID

  mentions: Optional[List[str]]
  hashtags: Optional[List[str]]

  reply_to: Optional[str]  # Message ID

  edited_at: Optional[datetime]
  delivered_at: Optional[datetime]
  scheduled_at: Optional[datetime]

  views: Optional[int]  # Group & Channel
  visited_at: Optional[datetime]  # Conversation

  originate_from: Optional[str]  # Account ID
  forwarded_from: Optional[str]  # Account ID

  reactions: Optional[List[Reaction]]


# ----------------------------------------
# Data Transfer Object Interface
# ----------------------------------------


class MessageDto[T: Any, Properties: Any](Dto[Properties]):
  type: MessageType

  content: T

  caption: Optional[str]
  channel: Optional[str]  # Channel ID
  account: Optional[str]  # Account ID

  mentions: Optional[List[str]]
  hashtags: Optional[List[str]]

  reply_to: Optional[str]  # Message ID

  edited_at: Optional[datetime]
  delivered_at: Optional[datetime]
  scheduled_at: Optional[datetime]

  views: Optional[int]  # Group & Channel
  visited_at: Optional[datetime]  # Conversation

  originate_from: Optional[str]  # Account ID
  forwarded_from: Optional[str]  # Account ID

  reactions: Optional[List[Reaction]]
