From 9b271da739a18a198e78a181b94ac67b64ec5aad Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 23 May 2023 17:20:34 +0800 Subject: [PATCH] RevokeMsg --- .../msgtransfer/online_msg_to_mongo_handler.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/msgtransfer/online_msg_to_mongo_handler.go b/internal/msgtransfer/online_msg_to_mongo_handler.go index 2f475c3a6..85f7211cc 100644 --- a/internal/msgtransfer/online_msg_to_mongo_handler.go +++ b/internal/msgtransfer/online_msg_to_mongo_handler.go @@ -3,6 +3,7 @@ package msgtransfer import ( "context" "encoding/json" + "errors" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" @@ -76,8 +77,17 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(ctx context.Cont log.ZError(ctx, "json.Unmarshal RevokeMsgTips", err, "content", string(v.Content)) continue } - v.Seq = tips.Seq - data, err := proto.Marshal(v) + msgs, err := mc.msgDatabase.GetMsgBySeqs(ctx, tips.ConversationID, []int64{tips.Seq}) + if err != nil { + log.ZError(ctx, "GetMsgBySeqs", err, "conversationID", tips.ConversationID, "seq", tips.Seq) + continue + } + if len(msgs) == 0 { + log.ZError(ctx, "GetMsgBySeqs empty", errors.New("seq not found"), "conversationID", tips.ConversationID, "seq", tips.Seq) + continue + } + msgs[0].Content = []byte(elem.Detail) + data, err := proto.Marshal(msgs[0]) if err != nil { log.ZError(ctx, "proto.Marshal MsgData", err) continue