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

33 lines
808 B
Python
Raw Normal View History

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,
}