feat: save registered accounts to postgres

This commit is contained in:
mmc
2026-03-19 14:32:17 +08:00
parent 6a250fe6a1
commit 2904e43b1f
11 changed files with 235 additions and 4 deletions

View File

@@ -155,6 +155,7 @@ class MailProvider(ABC):
class MailTmProvider(MailProvider):
def __init__(self, api_base: str = "https://api.mail.tm"):
self.api_base = api_base.rstrip("/")
self.last_mailbox_info: Dict[str, str] = {}
def _headers(self, token: str = "", use_json: bool = False) -> Dict[str, str]:
h: Dict[str, str] = {"Accept": "application/json"}
@@ -215,6 +216,11 @@ class MailTmProvider(MailProvider):
if token_resp.status_code == 200:
token = str(token_resp.json().get("token") or "").strip()
if token:
self.last_mailbox_info = {
"email": email,
"mail_password": password,
"mail_token": token,
}
return email, token
return "", ""
@@ -402,6 +408,7 @@ class DuckMailProvider(MailProvider):
self.api_base = api_base.rstrip("/")
self.bearer_token = bearer_token
self.domain = str(domain).strip()
self.last_mailbox_info: Dict[str, str] = {}
def _auth_headers(self, token: str = "") -> Dict[str, str]:
h: Dict[str, str] = {"Accept": "application/json"}
@@ -455,6 +462,11 @@ class DuckMailProvider(MailProvider):
if token_resp.status_code == 200:
mail_token = token_resp.json().get("token")
if mail_token:
self.last_mailbox_info = {
"email": email,
"mail_password": password,
"mail_token": str(mail_token),
}
return email, str(mail_token)
except Exception as exc:
logger.warning("DuckMail 创建邮箱失败: %s", exc)