ci: fix lint and test failures

This commit is contained in:
shaw 2026-05-07 19:26:18 +08:00
parent 57fd7998d3
commit 8a835b22bb
2 changed files with 33 additions and 15 deletions

View File

@ -646,12 +646,21 @@ func TestAPIContracts(t *testing.T) {
"registration_email_suffix_whitelist": [], "registration_email_suffix_whitelist": [],
"promo_code_enabled": true, "promo_code_enabled": true,
"password_reset_enabled": false, "password_reset_enabled": false,
"frontend_url": "", "frontend_url": "",
"totp_enabled": false, "totp_enabled": false,
"totp_encryption_key_configured": false, "totp_encryption_key_configured": false,
"smtp_host": "smtp.example.com", "login_agreement_enabled": false,
"smtp_port": 587, "login_agreement_mode": "modal",
"smtp_username": "user", "login_agreement_updated_at": "2026-03-31",
"login_agreement_documents": [
{"id": "terms", "title": "服务条款", "content_md": ""},
{"id": "usage-policy", "title": "使用政策", "content_md": ""},
{"id": "supported-regions", "title": "支持的国家和地区", "content_md": ""},
{"id": "service-specific-terms", "title": "服务特定条款", "content_md": ""}
],
"smtp_host": "smtp.example.com",
"smtp_port": 587,
"smtp_username": "user",
"smtp_password_configured": true, "smtp_password_configured": true,
"smtp_from_email": "no-reply@example.com", "smtp_from_email": "no-reply@example.com",
"smtp_from_name": "Sub2API", "smtp_from_name": "Sub2API",
@ -880,12 +889,21 @@ func TestAPIContracts(t *testing.T) {
"promo_code_enabled": true, "promo_code_enabled": true,
"password_reset_enabled": false, "password_reset_enabled": false,
"frontend_url": "", "frontend_url": "",
"invitation_code_enabled": false, "invitation_code_enabled": false,
"totp_enabled": false, "totp_enabled": false,
"totp_encryption_key_configured": false, "totp_encryption_key_configured": false,
"smtp_host": "", "login_agreement_enabled": false,
"smtp_port": 587, "login_agreement_mode": "modal",
"smtp_username": "", "login_agreement_updated_at": "2026-03-31",
"login_agreement_documents": [
{"id": "terms", "title": "服务条款", "content_md": ""},
{"id": "usage-policy", "title": "使用政策", "content_md": ""},
{"id": "supported-regions", "title": "支持的国家和地区", "content_md": ""},
{"id": "service-specific-terms", "title": "服务特定条款", "content_md": ""}
],
"smtp_host": "",
"smtp_port": 587,
"smtp_username": "",
"smtp_password_configured": false, "smtp_password_configured": false,
"smtp_from_email": "", "smtp_from_email": "",
"smtp_from_name": "", "smtp_from_name": "",

View File

@ -249,16 +249,16 @@ func normalizeLoginAgreementDocumentID(raw string) string {
lastSeparator := false lastSeparator := false
for _, r := range raw { for _, r := range raw {
if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') { if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') {
b.WriteRune(r) _, _ = b.WriteRune(r)
lastSeparator = false lastSeparator = false
continue continue
} }
if r == '-' || r == '_' || r == ' ' || r == '.' || r == '/' { if r == '-' || r == '_' || r == ' ' || r == '.' || r == '/' {
if !lastSeparator && b.Len() > 0 { if !lastSeparator && b.Len() > 0 {
if r == '_' { if r == '_' {
b.WriteRune('_') _, _ = b.WriteRune('_')
} else { } else {
b.WriteRune('-') _, _ = b.WriteRune('-')
} }
lastSeparator = true lastSeparator = true
} }