37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
from datetime import datetime
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class AliyunSmsStatus:
|
|
def __init__(self, gateway):
|
|
self._gateway = gateway
|
|
|
|
async def probe(self) -> bool:
|
|
try:
|
|
today = datetime.now().strftime("%Y%m%d")
|
|
await self._gateway.client.query_send_statistics(
|
|
start_date=today,
|
|
end_date=today,
|
|
page_size=1,
|
|
)
|
|
return True
|
|
except Exception as e:
|
|
logger.warning("阿里云短信探活失败: account=%s error=%s", self._gateway.account.account_id, e)
|
|
return False
|
|
|
|
def build_summary(self, snapshot: dict | None = None) -> dict:
|
|
account = self._gateway.account
|
|
return {
|
|
"status": "running" if self._gateway.running else "stopped",
|
|
"account_id": account.account_id,
|
|
"sign_name": account.sign_name,
|
|
"region": account.region,
|
|
"configured": account.is_configured(),
|
|
"dm_policy": account.dm_policy,
|
|
"phone_mask_enabled": account.phone_mask_enabled,
|
|
}
|