feat: 添加排除消息ID参数以优化聊天记录获取逻辑
This commit is contained in:
parent
36c1dc2136
commit
f8f0186665
@ -35,6 +35,7 @@ const agent = async (ctx: Context.Data) => {
|
||||
endTime,
|
||||
mentions,
|
||||
senderOpenId: openId,
|
||||
excludedMessageIds: [message_id, messageId],
|
||||
})
|
||||
// 如果没有聊天记录,返回错误信息
|
||||
if (chatHistory.length === 0) {
|
||||
|
@ -50,12 +50,14 @@ const getChatHistory = async (
|
||||
endTime,
|
||||
senderOpenId,
|
||||
mentions: targetUsers,
|
||||
excludedMessageIds = [], // 新增参数
|
||||
}: {
|
||||
chatId: string
|
||||
startTime: string
|
||||
endTime: string
|
||||
senderOpenId?: string
|
||||
mentions?: LarkEvent.Mention[]
|
||||
excludedMessageIds?: string[] // 新增参数类型
|
||||
}
|
||||
): Promise<{
|
||||
messages: Message[]
|
||||
@ -106,6 +108,10 @@ const getChatHistory = async (
|
||||
|
||||
// 遍历历史消息
|
||||
for (const chat of chatHistory) {
|
||||
// 过滤掉不需要的消息 ID
|
||||
if (excludedMessageIds.includes(chat.message_id)) {
|
||||
continue
|
||||
}
|
||||
if (chat.mentions) {
|
||||
for (const mention of chat.mentions) {
|
||||
mentions.set(mention.id, mention.name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user