ForcePilot/backend/package/yuxi/channel/extensions/webex/security.py

35 lines
984 B
Python
Raw Normal View History

from yuxi.channel.extensions.webex.types import WebexAccount
class WebexSecurity:
def __init__(self, account: WebexAccount):
self._account = account
def resolve_dm_policy(self, person_id: str) -> str:
policy = self._account.dm_policy
if policy == "disabled":
return "deny"
if policy == "allowlist":
if person_id not in self._account.allow_from:
return "deny"
return "allow"
if policy == "pairing":
return "pairing"
if policy == "open":
return "allow"
return "deny"
def resolve_space_policy(self, room_id: str) -> str:
policy = self._account.space_policy
if policy in ("at_mention", "always", "disabled"):
return policy
return "at_mention"
def is_bot_mentioned(self, mentions: list[dict], bot_person_id: str) -> bool:
return any(m.get("personId") == bot_person_id for m in mentions)