修复图片卡密发送与自动化延迟调度
图片卡密改为下载 URL 内容后按账号正常发送;批量铺货支持发布强制间隔;持久化延迟动作改为秒级调度,保留原有生命周期收口。
This commit is contained in:
1 parent
cad43780af
commit
3c46dd910b
20 files changed
+498
-42
No files matched your search
@@ -5,6 +5,7 @@ package cards
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -282,9 +283,14 @@ func validateDraft(draft Draft) error {
|
||||
return &ValidationError{Message: "数据卡密内容不能为空"}
|
||||
}
|
||||
case "image":
|
||||
// imageURL、err 分别保存规范化后的远程图片地址和 URL 解析错误。
|
||||
imageURL, err := url.Parse(strings.TrimSpace(draft.ImageURL))
|
||||
if strings.TrimSpace(draft.ImageURL) == "" {
|
||||
return &ValidationError{Message: "图片卡密 URL 不能为空"}
|
||||
}
|
||||
if err != nil || imageURL.Hostname() == "" || imageURL.User != nil || (imageURL.Scheme != "http" && imageURL.Scheme != "https") {
|
||||
return &ValidationError{Message: "图片卡密 URL 必须是 HTTP(S) 地址"}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -133,6 +133,8 @@ func TestServiceCreateValidation(t *testing.T) {
|
||||
{name: "empty-text", draft: Draft{Name: "x", Type: "text", TextContent: " "}, want: "文本卡密内容不能为空"},
|
||||
{name: "empty-data", draft: Draft{Name: "x", Type: "data", DataContent: "\n"}, want: "数据卡密内容不能为空"},
|
||||
{name: "empty-image", draft: Draft{Name: "x", Type: "image", ImageURL: ""}, want: "图片卡密 URL 不能为空"},
|
||||
{name: "non-http-image", draft: Draft{Name: "x", Type: "image", ImageURL: "file:///tmp/card.png"}, want: "图片卡密 URL 必须是 HTTP(S) 地址"},
|
||||
{name: "credential-image", draft: Draft{Name: "x", Type: "image", ImageURL: "https://user:[email protected]/card.png"}, want: "图片卡密 URL 必须是 HTTP(S) 地址"},
|
||||
} {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
// err 是当前非法输入返回的业务校验结果。
|
||||
|
||||
Reference in new issue
Block a user