refactor: 移除 SMTP 相关代码,简化用户创建流程,更新文档

This commit is contained in:
2026-04-13 12:27:14 +08:00
parent 919c561629
commit 66c254e0ff
13 changed files with 41 additions and 466 deletions
+1 -26
View File
@@ -20,7 +20,7 @@ settings = Dynaconf(
],
environments=True,
load_dotenv=True,
merge_enabled=True
merge_enabled=True,
)
@@ -55,25 +55,9 @@ class GiteaConfig(BaseModel):
token: SecretStr
email_domain: str = "tongji.edu.cn"
default_org: str = ""
password_length: int = 16
labels: list[LabelDef] = []
class SmtpConfig(BaseModel):
"""SMTP 邮件配置"""
model_config = ConfigDict(
alias_generator=AliasGenerator(validation_alias=str.upper),
populate_by_name=True,
)
host: str
port: int = 465
user: str
password: SecretStr
from_addr: str = ""
class Config(BaseModel):
"""总配置模型"""
@@ -85,7 +69,6 @@ class Config(BaseModel):
)
gitea: GiteaConfig
smtp: SmtpConfig | None = None
def get_config() -> Config:
@@ -96,11 +79,3 @@ def get_config() -> Config:
def get_gitea_config() -> GiteaConfig:
"""从 Dynaconf 加载并校验 Gitea 配置"""
return get_config().gitea
def get_smtp_config() -> SmtpConfig:
"""从 Dynaconf 加载并校验 SMTP 配置"""
cfg = get_config()
if cfg.smtp is None:
raise ValueError("SMTP 配置缺失, 请在 .secrets.toml 中配置")
return cfg.smtp