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

47 lines
1.6 KiB
Python
Raw Normal View History

import logging
logger = logging.getLogger(__name__)
class ClickUpSecurity:
def resolve_dm_policy(self) -> dict:
return {"mode": "open", "allow_from": []}
def resolve_dm_policy_for_account(self, account: dict) -> dict:
mode = account.get("dm_policy", "open")
return {"mode": mode, "allow_from": account.get("allow_from", [])}
async def check_allowlist(self, peer_id: str, channel_type: str) -> bool:
return True
def resolve_require_mention(self, ctx) -> bool | None:
config = getattr(ctx, "config", {}) if ctx else {}
channel_id = getattr(ctx, "channel_id", None) if ctx else None
if channel_id:
channels = config.get("channels", {})
channel_cfg = channels.get(channel_id, {})
if "require_mention" in channel_cfg:
return channel_cfg["require_mention"]
channel_policy = config.get("channel_policy", "activate_on_mention")
return channel_policy == "activate_on_mention"
def resolve_group_intro_hint(self, ctx) -> str | None:
return None
def resolve_tool_policy(self, ctx) -> dict | None:
return None
def apply_config_fixes(self, config: dict) -> dict:
return config
def collect_warnings(self, config: dict, account_id: str | None = None, account: dict | None = None) -> list[str]:
warnings = []
channel_policy = account.get("channel_policy", "") if account else config.get("channel_policy", "")
if channel_policy == "always" and not config.get("channels"):
warnings.append("channelPolicy is 'always' without channels allowlist")
return warnings