|
@@ -16,254 +16,75 @@
|
|
|
from typing import List, Any, Dict, Optional
|
|
|
|
|
|
from attr import dataclass
|
|
|
-from mautrix.types import SerializableAttrs, SerializableEnum
|
|
|
+from mautrix.types import SerializableAttrs
|
|
|
|
|
|
-from .account import BaseResponseUser, UserIdentifier
|
|
|
+from .account import BaseResponseUser
|
|
|
+from .thread_item import ThreadItem
|
|
|
|
|
|
|
|
|
-class ThreadItemType(SerializableEnum):
|
|
|
- DELETION = "deletion"
|
|
|
- MEDIA = "media"
|
|
|
- TEXT = "text"
|
|
|
- LIKE = "like"
|
|
|
- HASHTAG = "hashtag"
|
|
|
- PROFILE = "profile"
|
|
|
- MEDIA_SHARE = "media_share"
|
|
|
- LOCATION = "location"
|
|
|
- ACTION_LOG = "action_log"
|
|
|
- TITLE = "title"
|
|
|
- USER_REACTION = "user_reaction"
|
|
|
- HISTORY_EDIT = "history_edit"
|
|
|
- REACTION_LOG = "reaction_log"
|
|
|
- REEL_SHARE = "reel_share"
|
|
|
- DEPRECATED_CHANNEL = "deprecated_channel"
|
|
|
- LINK = "link"
|
|
|
- RAVEN_MEDIA = "raven_media"
|
|
|
- LIVE_VIDEO_SHARE = "live_video_share"
|
|
|
- TEST = "test"
|
|
|
- STORY_SHARE = "story_share"
|
|
|
- REEL_REACT = "reel_react"
|
|
|
- LIVE_INVITE_GUEST = "live_invite_guest"
|
|
|
- LIVE_VIEWER_INVITE = "live_viewer_invite"
|
|
|
- TYPE_MAX = "type_max"
|
|
|
- PLACEHOLDER = "placeholder"
|
|
|
- PRODUCT = "product"
|
|
|
- PRODUCT_SHARE = "product_share"
|
|
|
- VIDEO_CALL_EVENT = "video_call_event"
|
|
|
- POLL_VOTE = "poll_vote"
|
|
|
- FELIX_SHARE = "felix_share"
|
|
|
- ANIMATED_MEDIA = "animated_media"
|
|
|
- CTA_LINK = "cta_link"
|
|
|
- VOICE_MEDIA = "voice_media"
|
|
|
- STATIC_STICKER = "static_sticker"
|
|
|
- AR_EFFECT = "ar_effect"
|
|
|
- SELFIE_STICKER = "selfie_sticker"
|
|
|
- REACTION = "reaction"
|
|
|
+@dataclass
|
|
|
+class ThreadUser(BaseResponseUser, SerializableAttrs['ThreadUser']):
|
|
|
+ interop_messaging_user_fbid: int
|
|
|
+ is_using_unified_inbox_for_direct: bool
|
|
|
|
|
|
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class ThreadItemActionLog(SerializableAttrs['ThreadItemActionLog']):
|
|
|
- description: str
|
|
|
- # TODO bold, text_attributes
|
|
|
-
|
|
|
-
|
|
|
-class ViewMode(SerializableEnum):
|
|
|
- ONCE = "once"
|
|
|
- REPLAYABLE = "replayable"
|
|
|
- PERMANENT = "permanent"
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class CreativeConfig(SerializableAttrs['CreativeConfig']):
|
|
|
- capture_type: str
|
|
|
- camera_facing: str
|
|
|
- should_render_try_it_on: bool
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class CreateModeAttribution(SerializableAttrs['CreateModeAttribution']):
|
|
|
- type: str
|
|
|
- name: str
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class ImageVersion(SerializableAttrs['ImageVersion']):
|
|
|
- width: int
|
|
|
- height: int
|
|
|
- url: str
|
|
|
- estimated_scan_sizes: Optional[List[int]] = None
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class ImageVersions(SerializableAttrs['ImageVersions']):
|
|
|
- candidates: List[ImageVersion]
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class VideoVersion(SerializableAttrs['VideoVersion']):
|
|
|
- type: int
|
|
|
- width: int
|
|
|
- height: int
|
|
|
- url: str
|
|
|
- id: str
|
|
|
-
|
|
|
-
|
|
|
-class MediaType(SerializableEnum):
|
|
|
- IMAGE = 1
|
|
|
- VIDEO = 2
|
|
|
- AD_MAP = 6
|
|
|
- LIVE = 7
|
|
|
- CAROUSEL = 8
|
|
|
- LIVE_REPLAY = 9
|
|
|
- COLLECTION = 10
|
|
|
- AUDIO = 11
|
|
|
- SHOWREEL_NATIVE = 12
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class RegularMediaItem(SerializableAttrs['RegularMediaItem']):
|
|
|
- id: str
|
|
|
- image_versions2: Optional[ImageVersions] = None
|
|
|
- video_versions: Optional[List[VideoVersion]] = None
|
|
|
- original_width: int
|
|
|
- original_height: int
|
|
|
- media_type: MediaType
|
|
|
- media_id: Optional[int] = None
|
|
|
- organic_tracking_token: Optional[str] = None
|
|
|
- creative_config: Optional[CreativeConfig] = None
|
|
|
- create_mode_attribution: Optional[CreateModeAttribution] = None
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class Caption(SerializableAttrs['Caption']):
|
|
|
- pk: int
|
|
|
- user_id: int
|
|
|
- text: str
|
|
|
- # TODO enum?
|
|
|
- type: int
|
|
|
- created_at: int
|
|
|
- created_at_utc: int
|
|
|
- content_type: str
|
|
|
- # TODO enum?
|
|
|
- status: str
|
|
|
- bit_flags: int
|
|
|
- user: BaseResponseUser
|
|
|
- did_report_as_spam: bool
|
|
|
- share_enabled: bool
|
|
|
- media_id: int
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class MediaShareItem(SerializableAttrs['MediaShareItem']):
|
|
|
- taken_at: int
|
|
|
- pk: int
|
|
|
+@dataclass
|
|
|
+class ThreadTheme(SerializableAttrs['ThreadTheme']):
|
|
|
id: str
|
|
|
- device_timestamp: int
|
|
|
- media_type: MediaType
|
|
|
- code: str
|
|
|
- client_cache_key: str
|
|
|
- filter_type: int
|
|
|
- image_versions2: ImageVersions
|
|
|
- video_versions: VideoVersion
|
|
|
- original_width: int
|
|
|
- original_height: int
|
|
|
- user: BaseResponseUser
|
|
|
- can_viewer_reshare: bool
|
|
|
- caption_is_edited: bool
|
|
|
- comment_likes_enabled: bool
|
|
|
- comment_threading_enabled: bool
|
|
|
- has_more_comments: bool
|
|
|
- max_num_visible_preview_comments: int
|
|
|
- can_view_more_preview_comments: bool
|
|
|
- comment_count: int
|
|
|
- like_count: int
|
|
|
- has_liked: bool
|
|
|
- photo_of_you: bool
|
|
|
- caption: Caption
|
|
|
- can_viewer_save: bool
|
|
|
- organic_tracking_token: str
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class ReplayableMediaItem(SerializableAttrs['ReplayableMediaItem']):
|
|
|
- view_mode: ViewMode
|
|
|
- seen_count: int
|
|
|
- seen_user_ids: List[int]
|
|
|
- replay_expiring_at_us: Optional[Any] = None
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class VisualMedia(ReplayableMediaItem, SerializableAttrs['VisualMedia']):
|
|
|
- url_expire_at_secs: int
|
|
|
- playback_duration_secs: int
|
|
|
- media: RegularMediaItem
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class AudioInfo(SerializableAttrs['AudioInfo']):
|
|
|
- audio_src: str
|
|
|
- duration: int
|
|
|
- waveform_data: List[int]
|
|
|
- waveform_sampling_frequence_hz: int
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class VoiceMediaData(SerializableAttrs['VoiceMediaData']):
|
|
|
- id: str
|
|
|
- audio: AudioInfo
|
|
|
- organic_tracking_token: str
|
|
|
- user: UserIdentifier
|
|
|
- # TODO enum?
|
|
|
- product_type: str = "direct_audio"
|
|
|
- media_type: MediaType = MediaType.AUDIO
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class VoiceMediaItem(ReplayableMediaItem, SerializableAttrs['VoiceMediaItem']):
|
|
|
- media: VoiceMediaData
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class AnimatedMediaImage(SerializableAttrs['AnimatedMediaImage']):
|
|
|
- height: str
|
|
|
- mp4: str
|
|
|
- mp4_size: str
|
|
|
- size: str
|
|
|
- url: str
|
|
|
- webp: str
|
|
|
- webp_size: str
|
|
|
- width: str
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class AnimatedMediaImages(SerializableAttrs['AnimatedMediaImages']):
|
|
|
- fixed_height: Optional[AnimatedMediaImage] = None
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class AnimatedMediaItem(SerializableAttrs['AnimatedMediaItem']):
|
|
|
- id: str
|
|
|
- is_random: str
|
|
|
- is_sticker: str
|
|
|
- images: AnimatedMediaImages
|
|
|
-
|
|
|
-
|
|
|
-@dataclass(kw_only=True)
|
|
|
-class ThreadItem(SerializableAttrs['ThreadItem']):
|
|
|
- item_id: Optional[str] = None
|
|
|
- user_id: Optional[int] = None
|
|
|
- timestamp: int
|
|
|
- item_type: Optional[ThreadItemType] = None
|
|
|
- is_shh_mode: bool = False
|
|
|
|
|
|
- text: Optional[str] = None
|
|
|
- client_context: Optional[str] = None
|
|
|
- show_forward_attribution: Optional[bool] = None
|
|
|
- action_log: Optional[ThreadItemActionLog] = None
|
|
|
|
|
|
- # These have only been observed over MQTT and not confirmed in direct_inbox
|
|
|
- media: Optional[RegularMediaItem] = None
|
|
|
- voice_media: Optional[VoiceMediaItem] = None
|
|
|
- animated_media: Optional[AnimatedMediaItem] = None
|
|
|
- visual_media: Optional[VisualMedia] = None
|
|
|
- media_share: Optional[MediaShareItem] = None
|
|
|
+@dataclass
|
|
|
+class ThreadUserLastSeenAt(SerializableAttrs['UserLastSeenAt']):
|
|
|
+ timestamp: str
|
|
|
+ item_id: str
|
|
|
+ shh_seen_state: Dict[str, Any]
|
|
|
+
|
|
|
+
|
|
|
+@dataclass
|
|
|
+class Thread(SerializableAttrs['Thread']):
|
|
|
+ thread_id: str
|
|
|
+ thread_v2_id: str
|
|
|
+
|
|
|
+ users: List[ThreadUser]
|
|
|
+ inviter: BaseResponseUser
|
|
|
+ admin_user_ids: List[int]
|
|
|
+
|
|
|
+ last_activity_at: int
|
|
|
+ muted: bool
|
|
|
+ is_pin: bool
|
|
|
+ named: bool
|
|
|
+ canonical: bool
|
|
|
+ pending: bool
|
|
|
+ archived: bool
|
|
|
+ # TODO enum? even groups seem to be "private"
|
|
|
+ thread_type: str
|
|
|
+ viewer_id: int
|
|
|
+ thread_title: str
|
|
|
+ folder: int
|
|
|
+ vc_muted: bool
|
|
|
+ is_group: bool
|
|
|
+ mentions_muted: bool
|
|
|
+ approval_required_for_new_members: bool
|
|
|
+ input_mode: int
|
|
|
+ business_thread_folder: int
|
|
|
+ read_state: int
|
|
|
+ last_non_sender_item_at: int
|
|
|
+ assigned_admin_id: int
|
|
|
+ shh_mode_enabled: bool
|
|
|
+ is_close_friend_thread: bool
|
|
|
+ has_older: bool
|
|
|
+ has_newer: bool
|
|
|
+
|
|
|
+ theme: ThreadTheme
|
|
|
+ last_seen_at: Dict[int, ThreadUserLastSeenAt]
|
|
|
+
|
|
|
+ newest_cursor: str
|
|
|
+ oldest_cursor: str
|
|
|
+ next_cursor: str
|
|
|
+ prev_cursor: str
|
|
|
+ last_permanent_item: ThreadItem
|
|
|
+ items: List[ThreadItem]
|
|
|
+
|
|
|
+ # These might only be in single thread requests and not inbox
|
|
|
+ valued_request: Optional[bool] = None
|
|
|
+ pending_score: Optional[bool] = None
|