Merge branch 'v2'

This commit is contained in:
fuzhongyun 2025-11-14 13:11:24 +08:00
commit 535864f0a6
2 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,9 @@
package util package util
import "strings" import (
"encoding/json"
"strings"
)
// 占位符替换 xxx{placeholder}xxx // 占位符替换 xxx{placeholder}xxx
func ReplacePlaceholder(str string, placeholder string, value string) string { func ReplacePlaceholder(str string, placeholder string, value string) string {
@ -11,3 +14,8 @@ func ReplacePlaceholder(str string, placeholder string, value string) string {
func BuildJumpLink(url string, text string) string { func BuildJumpLink(url string, text string) string {
return "<a href=\"" + url + "\" target=\"_blank\">" + text + "</a>" return "<a href=\"" + url + "\" target=\"_blank\">" + text + "</a>"
} }
func EscapeJSONString(s string) string {
b, _ := json.Marshal(s)
return string(b[1 : len(b)-1])
}

View File

@ -145,7 +145,7 @@ func (s *CallbackService) handleDingTalkCallback(c *fiber.Ctx, env Envelope) err
msg := data.Msg msg := data.Msg
msg = util.ReplacePlaceholder(msg, "receivers", receivers) msg = util.ReplacePlaceholder(msg, "receivers", receivers)
msg = util.ReplacePlaceholder(msg, "detail_page", detailPage) msg = util.ReplacePlaceholder(msg, "detail_page", util.EscapeJSONString(detailPage))
s.gateway.SendToUid(sessionID, []byte(msg)) s.gateway.SendToUid(sessionID, []byte(msg))