mirror of
https://github.com/cnlimiter/codex-register.git
synced 2026-07-05 22:31:41 +08:00
feat(mail): Temp-Mail 服务类型实现完成
This commit is contained in:
@@ -143,6 +143,7 @@ async def get_email_services_stats():
|
||||
stats = {
|
||||
'outlook_count': 0,
|
||||
'custom_count': 0,
|
||||
'temp_mail_count': 0,
|
||||
'tempmail_available': True, # 临时邮箱始终可用
|
||||
'enabled_count': enabled_count
|
||||
}
|
||||
@@ -152,6 +153,8 @@ async def get_email_services_stats():
|
||||
stats['outlook_count'] = count
|
||||
elif service_type == 'custom_domain':
|
||||
stats['custom_count'] = count
|
||||
elif service_type == 'temp_mail':
|
||||
stats['temp_mail_count'] = count
|
||||
|
||||
return stats
|
||||
|
||||
@@ -190,6 +193,17 @@ async def get_service_types():
|
||||
{"name": "api_key", "label": "API Key", "required": True},
|
||||
{"name": "default_domain", "label": "默认域名", "required": False},
|
||||
]
|
||||
},
|
||||
{
|
||||
"value": "temp_mail",
|
||||
"label": "Temp-Mail(自部署)",
|
||||
"description": "自部署 Cloudflare Worker 临时邮箱,admin 模式管理",
|
||||
"config_fields": [
|
||||
{"name": "base_url", "label": "Worker 地址", "required": True, "placeholder": "https://mail.example.com"},
|
||||
{"name": "admin_password", "label": "Admin 密码", "required": True, "secret": True},
|
||||
{"name": "domain", "label": "邮箱域名", "required": True, "placeholder": "example.com"},
|
||||
{"name": "enable_prefix", "label": "启用前缀", "required": False, "default": True},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -930,6 +930,11 @@ async def get_available_email_services():
|
||||
"available": False,
|
||||
"count": 0,
|
||||
"services": []
|
||||
},
|
||||
"temp_mail": {
|
||||
"available": False,
|
||||
"count": 0,
|
||||
"services": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,6 +989,25 @@ async def get_available_email_services():
|
||||
"from_settings": True
|
||||
})
|
||||
|
||||
# 获取 TempMail 服务(自部署 Cloudflare Worker 临时邮箱)
|
||||
temp_mail_services = db.query(EmailServiceModel).filter(
|
||||
EmailServiceModel.service_type == "temp_mail",
|
||||
EmailServiceModel.enabled == True
|
||||
).order_by(EmailServiceModel.priority.asc()).all()
|
||||
|
||||
for service in temp_mail_services:
|
||||
config = service.config or {}
|
||||
result["temp_mail"]["services"].append({
|
||||
"id": service.id,
|
||||
"name": service.name,
|
||||
"type": "temp_mail",
|
||||
"domain": config.get("domain"),
|
||||
"priority": service.priority
|
||||
})
|
||||
|
||||
result["temp_mail"]["count"] = len(temp_mail_services)
|
||||
result["temp_mail"]["available"] = len(temp_mail_services) > 0
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user