ForcePilot/backend/package/yuxi/channel/extensions/bluebubbles/session.py

17 lines
625 B
Python
Raw Normal View History

from yuxi.channel.extensions.bluebubbles.targets import extract_handle_from_chat_guid, is_group_chat_guid
def build_dm_session_key(agent_id: str, chat_guid: str) -> str:
handle = extract_handle_from_chat_guid(chat_guid)
return f"agent:{agent_id}:bluebubbles:dm:{handle}"
def build_group_session_key(agent_id: str, chat_guid: str) -> str:
return f"agent:{agent_id}:bluebubbles:group:{chat_guid}"
def build_session_key(agent_id: str, chat_guid: str) -> str:
if is_group_chat_guid(chat_guid):
return build_group_session_key(agent_id, chat_guid)
return build_dm_session_key(agent_id, chat_guid)