ForcePilot/backend/package/yuxi/channel/extensions/aliyun_sms/security.py
Kris b8864ac12f feat(aliyun-sms): 新增阿里云短信渠道插件
实现完整的阿里云短信服务接入能力,包含短信发送、状态回执处理、上行消息接收、安全策略校验、会话管理等功能
2026-05-21 10:39:43 +08:00

33 lines
808 B
Python

from __future__ import annotations
import logging
logger = logging.getLogger(__name__)
class AliyunSmsSecurity:
def __init__(self, gateway):
self._gateway = gateway
async def check_allowlist(self, phone_number: str) -> bool:
account = self._gateway.account
dm_policy = account.dm_policy
if dm_policy == "open":
return True
if dm_policy == "disabled":
return False
if dm_policy == "allowlist":
return phone_number in account.allow_from
if dm_policy == "pairing":
return True
return False
def resolve_dm_policy(self) -> dict:
account = self._gateway.account
return {
"mode": account.dm_policy,
"allow_from": account.allow_from,
}