mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-13 11:53:42 +08:00
feat: update i18n messages and improve error handling
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
{
|
||||
"success": "Success",
|
||||
"unauthorized": "Unauthorized",
|
||||
"forbidden": "Forbidden",
|
||||
"invalid_token": "Invalid token",
|
||||
"channel_not_found": "Channel not found",
|
||||
"invalid_request": "Invalid request",
|
||||
"internal_error": "Internal server error",
|
||||
"quota_exceeded": "Quota exceeded",
|
||||
"invalid_input": "Invalid input, please check your input"
|
||||
"invalid_input": "Invalid input, please check your input",
|
||||
"send_email_failed": "failed to send email: ",
|
||||
"invalid_parameter": "invalid parameter"
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
{
|
||||
"success": "成功",
|
||||
"unauthorized": "未授权",
|
||||
"forbidden": "禁止访问",
|
||||
"invalid_token": "无效的令牌",
|
||||
"channel_not_found": "未找到渠道",
|
||||
"invalid_request": "无效的请求",
|
||||
"internal_error": "服务器内部错误",
|
||||
"quota_exceeded": "配额已用尽",
|
||||
"invalid_input": "无效的输入,请检查您的输入"
|
||||
"invalid_input": "无效的输入,请检查您的输入",
|
||||
"send_email_failed": "发送邮件失败:",
|
||||
"invalid_parameter": "无效的参数"
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ import (
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"net"
|
||||
"net/smtp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
)
|
||||
|
||||
func shouldAuth() bool {
|
||||
@@ -98,8 +99,8 @@ func SendEmail(subject string, receiver string, content string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err = smtp.SendMail(addr, auth, config.SMTPAccount, to, mail)
|
||||
return nil
|
||||
}
|
||||
err = smtp.SendMail(addr, auth, config.SMTPAccount, to, mail)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user