ForcePilot/backend/package/yuxi/channel/extensions/zoomchat/threading.py

29 lines
930 B
Python
Raw Normal View History

import logging
from yuxi.channel.protocols import ReplyTransport
logger = logging.getLogger(__name__)
class ZoomThreading:
def extract_thread_id(self, msg: dict) -> str | None:
raw = msg.get("raw_payload", {})
inner = raw.get("payload", {}).get("object", {})
thread_root = inner.get("thread_root_message_id")
if thread_root:
return thread_root
reply_to = msg.get("reply_to_id") or msg.get("message_thread_id")
if reply_to:
return reply_to
msg_id = msg.get("msg_id")
return msg_id if msg_id else None
def resolve_reply_transport(self, msg: dict, thread_id: str | None) -> ReplyTransport:
if thread_id:
return ReplyTransport(mode="thread", thread_id=thread_id)
msg_id = msg.get("msg_id", "")
return ReplyTransport(mode="thread", thread_id=msg_id) if msg_id else ReplyTransport(mode="inline")