优化站内信模块
This commit is contained in:
@@ -97,12 +97,44 @@ type emailFormPayload struct {
|
||||
Password string `json:"password"`
|
||||
Encryption string `json:"encryption"`
|
||||
Timeout interface{} `json:"timeout"`
|
||||
Status interface{} `json:"status"`
|
||||
}
|
||||
type testEmailPayload struct {
|
||||
emailFormPayload
|
||||
TestEmail string `json:"testEmail"`
|
||||
}
|
||||
|
||||
func parseInt8Flexible(v interface{}) int8 {
|
||||
if v == nil {
|
||||
return 1
|
||||
}
|
||||
switch x := v.(type) {
|
||||
case bool:
|
||||
if x {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
case float64:
|
||||
return int8(x)
|
||||
case int:
|
||||
return int8(x)
|
||||
case int8:
|
||||
return x
|
||||
case string:
|
||||
s := strings.TrimSpace(x)
|
||||
if s == "" {
|
||||
return 1
|
||||
}
|
||||
n, err := strconv.ParseInt(s, 10, 8)
|
||||
if err != nil {
|
||||
return 1
|
||||
}
|
||||
return int8(n)
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
func parseUintFlexible(v interface{}) uint {
|
||||
if v == nil {
|
||||
return 0
|
||||
@@ -191,7 +223,8 @@ func (c *PlatformEmailController) EditInfo() {
|
||||
s := strings.TrimSpace(p.FromName)
|
||||
fn = &s
|
||||
}
|
||||
err = services.UpsertFirstSystemEmail(from, fn, host, port, strings.TrimSpace(p.Password), enc, timeout, 1, nil)
|
||||
status := parseInt8Flexible(p.Status)
|
||||
err = services.UpsertFirstSystemEmail(from, fn, host, port, strings.TrimSpace(p.Password), enc, timeout, status, nil)
|
||||
if err != nil {
|
||||
c.jsonErr(500, 500, "保存邮箱配置失败: "+err.Error())
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user