|
@@ -5,6 +5,7 @@ import (
|
|
|
"errors"
|
|
|
"github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
|
"regexp"
|
|
|
+ "strings"
|
|
|
"wechat-api/ent"
|
|
|
"wechat-api/ent/contact"
|
|
|
"wechat-api/ent/custom_types"
|
|
@@ -156,13 +157,14 @@ func (l *PublishSopTaskLogic) PublishSopTask(req *types.IDReq) (resp *types.Base
|
|
|
if message.Meta != nil {
|
|
|
meta.Filename = message.Meta.Filename
|
|
|
}
|
|
|
+ content := varReplace(message.Content, c)
|
|
|
_, err = l.svcCtx.DB.MessageRecords.Create().
|
|
|
SetBotWxid(c.WxWxid).
|
|
|
SetContactID(0).
|
|
|
SetContactType(0).
|
|
|
SetContactWxid(forwardWxid).
|
|
|
SetContentType(message.Type).
|
|
|
- SetContent(message.Content).
|
|
|
+ SetContent(content).
|
|
|
SetMeta(meta).
|
|
|
SetSourceType(sourceType).
|
|
|
SetSourceID(stage.ID).
|
|
@@ -431,3 +433,12 @@ func splitString(input string) []string {
|
|
|
// Split the input string based on the pattern
|
|
|
return re.Split(input, -1)
|
|
|
}
|
|
|
+
|
|
|
+func varReplace(s string, contactInfo *ent.Contact) string {
|
|
|
+ nickname := ""
|
|
|
+ if contactInfo != nil {
|
|
|
+ nickname = contactInfo.Nickname
|
|
|
+ }
|
|
|
+ s = strings.Replace(s, "${nickname}", nickname, -1)
|
|
|
+ return s
|
|
|
+}
|