32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
|
|
class EmailSmtpSecurityAdapter:
|
|
def resolve_dm_policy(self, config: dict | None = None) -> dict:
|
|
return {"mode": "open", "allow_from": []}
|
|
|
|
def check_allowlist(self, sender_email: str) -> bool:
|
|
config = self._load_config()
|
|
policy = config.get("dm_policy", "open")
|
|
if policy == "open":
|
|
return True
|
|
if policy == "disabled":
|
|
return False
|
|
if policy == "allowlist":
|
|
allowlist = config.get("allowlist", [])
|
|
return sender_email.lower() in [a.lower() for a in allowlist]
|
|
if policy == "pairing":
|
|
return True
|
|
return False
|
|
|
|
def collect_warnings(self, config: dict, account_id: str | None = None, account: dict | None = None) -> list[str]:
|
|
return []
|
|
|
|
@staticmethod
|
|
def _load_config() -> dict:
|
|
try:
|
|
from yuxi.config import get_channel_config
|
|
return get_channel_config("email-smtp") or {}
|
|
except ImportError:
|
|
return {}
|