This commit is contained in:
richboo111
2024-01-24 09:41:19 +08:00
parent 4755c7ed9b
commit 8241434e91
2 changed files with 22 additions and 15 deletions

View File

@@ -472,7 +472,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
flag = false
vendorID int
errList errlist.ErrList
apply AutoReply
apply *AutoReply
jxMsg = &JXMsg{}
userList = &UserMessageList{}
)
@@ -484,7 +484,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
flag = GetIfReply(key)
//判断flag状态
if !flag {
apply = AutoReply{
apply = &AutoReply{
UserID: mt.AppID,
MsgID: mt.MsgID,
IsApply: true,
@@ -533,7 +533,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
//1 检测是否已自动回复
flag = GetIfReply(key)
if !flag {
apply = AutoReply{
apply = &AutoReply{
UserID: utils.Str2Int(elm.PayLoad.SenderID),
MsgID: utils.Str2Int(elm.PayLoad.MsgID),
IsApply: true,
@@ -579,18 +579,24 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
}
}
//1 存储详细聊天记录list
if err = SetMessageDetail(jxMsg, vendorID, elmAppID); err != nil {
errList.AddErr(fmt.Errorf("自动回复:存储详细聊天记录错误:%v", err))
if jxMsg != nil {
//1 存储详细聊天记录list
if err = SetMessageDetail(jxMsg, vendorID, elmAppID); err != nil {
errList.AddErr(fmt.Errorf("自动回复:存储详细聊天记录错误:%v", err))
}
//2 存储展示列表时单条数据
if err = SetUserList(jxMsg, userList, vendorID, elmAppID); err != nil {
errList.AddErr(fmt.Errorf("自动回复存储STU聊天记录错误%v", err))
}
}
//2 存储展示列表时单条数据
if err = SetUserList(jxMsg, userList, vendorID, elmAppID); err != nil {
errList.AddErr(fmt.Errorf("自动回复存储STU聊天记录错误%v", err))
}
//3 记录自动回复状态
if err = RecordAutoStatus(key, apply); err != nil {
errList.AddErr(fmt.Errorf("自动回复:记录自动回复状态错误:%v", err))
if apply != nil {
//3 记录自动回复状态
if err = RecordAutoStatus(key, apply); err != nil {
errList.AddErr(fmt.Errorf("自动回复:记录自动回复状态错误:%v", err))
}
}
if errList.GetErrListAsOne() != nil {
return fmt.Errorf("CheckAndReply err=%v", errList.GetErrListAsOne())
}
@@ -613,7 +619,7 @@ func GetIfReply(key string) (flag bool) {
}
// RecordAutoStatus 记录是否已自动回复状态
func RecordAutoStatus(key string, apply AutoReply) error {
func RecordAutoStatus(key string, apply *AutoReply) error {
data, _ := json.Marshal(apply)
err := rdb.RPush(key, string(data))
ok, err := rdb.ExpireResult(key, ExpireTimeDay)

View File

@@ -2,6 +2,7 @@ package mtwm
import (
"encoding/json"
"git.rosy.net.cn/baseapi/utils"
"net/http"
"strings"
@@ -122,7 +123,7 @@ func GetMsgCallBackUrl(msgType, appId string) string {
// OnImMsg im消息回调
func OnImMsg(msg *mtwmapi.ImCallbackMsg) (response *mtwmapi.CallbackResponse) {
globals.SugarLogger.Debugf("OnImMsg test0124 msg:=%s", utils.Format4Output(msg, false))
if str, err := json.Marshal(msg.PushContent); err == nil {
err = im.ReadMsgFromVendor(model.VendorIDMTWM, "", str)
if err != nil {