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