You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fb_export.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from __future__ import annotations
  2. from typing import Any, List, Set
  3. from pydantic import BaseModel
  4. from million.model.message import Message
  5. from million.model.participant import Participant
  6. class Image(BaseModel):
  7. creation_timestamp: int
  8. uri: str
  9. def __eq__(self, other: Image) -> bool:
  10. return self.creation_timestamp == other.creation_timestamp \
  11. and self.uri == other.uri
  12. class JoinableMode(BaseModel):
  13. mode: int
  14. link: str
  15. class FacebookExport(BaseModel):
  16. messages: List[Message]
  17. participants: Set[Participant]
  18. title: str
  19. is_still_participant: bool
  20. thread_path: str
  21. magic_words: Set[Any]
  22. image: Image
  23. joinable_mode: JoinableMode
  24. def merge(self, other: FacebookExport) -> None:
  25. if self == other:
  26. self.messages.extend(other.messages)
  27. self.participants.update(other.participants)
  28. self.magic_words.update(other.magic_words)
  29. def sort(self) -> None:
  30. self.messages.sort(key = lambda m: m.timestamp_ms)
  31. # NOTE Toughen equality conditions ?
  32. def __eq__(self, other: FacebookExport) -> bool:
  33. return self.title == other.title \
  34. and self.image == other.image