From 287b028ba8baa8bb096e91dc3937d70028ff5037 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Sat, 6 May 2023 11:48:03 +0800 Subject: [PATCH] msg --- pkg/common/db/cache/msg.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/common/db/cache/msg.go b/pkg/common/db/cache/msg.go index 9febd2913..4438f2ba0 100644 --- a/pkg/common/db/cache/msg.go +++ b/pkg/common/db/cache/msg.go @@ -254,11 +254,11 @@ func (c *msgCache) allMessageCacheKey(conversationID string) string { return messageCache + conversationID + "_*" } -func (c *msgCache) GetMessagesBySeq(ctx context.Context, userID string, seqs []int64) (seqMsgs []*sdkws.MsgData, failedSeqs []int64, err error) { +func (c *msgCache) GetMessagesBySeq(ctx context.Context, conversationID string, seqs []int64) (seqMsgs []*sdkws.MsgData, failedSeqs []int64, err error) { pipe := c.rdb.Pipeline() for _, v := range seqs { //MESSAGE_CACHE:169.254.225.224_reliability1653387820_0_1 - key := c.getMessageCacheKey(userID, v) + key := c.getMessageCacheKey(conversationID, v) if err := pipe.Get(ctx, key).Err(); err != nil && err != redis.Nil { return nil, nil, err } @@ -273,7 +273,11 @@ func (c *msgCache) GetMessagesBySeq(ctx context.Context, userID string, seqs []i if err != nil { failedSeqs = append(failedSeqs, seqs[i]) } else { - seqMsgs = append(seqMsgs, &msg) + if msg.Status != constant.MsgDeleted { + seqMsgs = append(seqMsgs, &msg) + } else { + failedSeqs = append(failedSeqs, seqs[i]) + } } } }