feat(mail): 添加收件箱功能,自动获得验证码

This commit is contained in:
cnlimiter
2026-03-20 12:54:39 +08:00
parent 87ff48cdaf
commit b1a8d02353
16 changed files with 186 additions and 44 deletions

View File

@@ -42,7 +42,7 @@ class Account(Base):
client_id = Column(String(255)) # OAuth Client ID
account_id = Column(String(255))
workspace_id = Column(String(255))
email_service = Column(String(50), nullable=False) # 'tempmail', 'outlook', 'custom_domain'
email_service = Column(String(50), nullable=False) # 'tempmail', 'outlook', 'moe_mail'
email_service_id = Column(String(255)) # 邮箱服务中的ID
proxy_used = Column(String(255))
registered_at = Column(DateTime, default=datetime.utcnow)
@@ -89,7 +89,7 @@ class EmailService(Base):
__tablename__ = 'email_services'
id = Column(Integer, primary_key=True, autoincrement=True)
service_type = Column(String(50), nullable=False) # 'outlook', 'custom_domain'
service_type = Column(String(50), nullable=False) # 'outlook', 'moe_mail'
name = Column(String(100), nullable=False)
config = Column(JSONEncodedDict, nullable=False) # 服务配置(加密存储)
enabled = Column(Boolean, default=True)

View File

@@ -117,6 +117,14 @@ class DatabaseSessionManager:
Base.metadata.create_all(bind=self.engine)
with self.engine.connect() as conn:
# 数据迁移:将旧的 custom_domain 记录统一为 moe_mail
try:
conn.execute(text("UPDATE email_services SET service_type='moe_mail' WHERE service_type='custom_domain'"))
conn.execute(text("UPDATE accounts SET email_service='moe_mail' WHERE email_service='custom_domain'"))
conn.commit()
except Exception as e:
logger.warning(f"迁移 custom_domain -> moe_mail 时出错: {e}")
for table_name, column_name, column_type in migrations:
try:
# 检查列是否存在