修复问题

This commit is contained in:
zpc 2024-08-05 17:22:43 +08:00
parent 21840be6b1
commit e9c8499fca

View File

@ -21,6 +21,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace HuanMeng.MiaoYu.Code.Chat
@ -497,12 +498,26 @@ namespace HuanMeng.MiaoYu.Code.Chat
var info = Mapper.Map<ChatHistoryInfo>(model);
//获取最新的聊天记录
var c = Dao.daoDbMiaoYu.context.T_Chat.Where(it => it.SessionId == it.SessionId).OrderByDescending(it => it.SendMessageDay).FirstOrDefault();
//var c = Dao.daoDbMiaoYu.context.T_Chat.Where(it => it.SessionId == it.SessionId).OrderByDescending(it => it.SendMessageDay).FirstOrDefault();
info.LastContactTime = it.UpdateAt;
if (c != null)
info.LastMessage = it.LastMessage;
if (string.IsNullOrEmpty(info.LastMessage))
{
info.LastMessage = c.Content;
info.LastMessage = model.Prologue;
if (info.LastMessage.IndexOf("*") > -1)
{
// 定义正则表达式模式来匹配*号之间的文本
string pattern = @"\*.*?\*";
// 使用正则表达式替换*号之间的文本为空
info.LastMessage = Regex.Replace(info.LastMessage, pattern, "");
}
}
//if (c != null)
//{
// info.LastMessage = c.Content;
//}
chatHistoryInfos.Add(info);
}
});