Skip to content

Commit

Permalink
fix: quote message change to revoke message when app from background …
Browse files Browse the repository at this point in the history
…to foreground and message status update. (#825)

Signed-off-by: Gordon <[email protected]>
  • Loading branch information
FGadvancer authored Dec 18, 2024
1 parent c3f148d commit 9270ddc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions internal/conversation_msg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,11 @@ func (c *Conversation) SendMessage(ctx context.Context, s *sdk_struct.MsgStruct,
case constant.Merger:
s.Content = utils.StructToJsonString(s.MergeElem)
case constant.Quote:
quoteMessage, err := c.db.GetMessage(ctx, lc.ConversationID, s.QuoteElem.QuoteMessage.ClientMsgID)
if err != nil {
log.ZWarn(ctx, "quote message not found", err)
}
s.QuoteElem.QuoteMessage.Seq = quoteMessage.Seq
s.Content = utils.StructToJsonString(s.QuoteElem)
case constant.Card:
s.Content = utils.StructToJsonString(s.CardElem)
Expand Down
8 changes: 7 additions & 1 deletion internal/conversation_msg/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,19 @@ func MsgDataToLocalChatLog(serverMessage *sdkws.MsgData) *model_struct.LocalChat
ContentType: serverMessage.ContentType,
Content: string(serverMessage.Content),
IsRead: serverMessage.IsRead,
Status: constant.MsgStatusSendSuccess,
Seq: serverMessage.Seq,
SendTime: serverMessage.SendTime,
CreateTime: serverMessage.CreateTime,
AttachedInfo: serverMessage.AttachedInfo,
Ex: serverMessage.Ex,
}

if serverMessage.Status >= constant.MsgStatusHasDeleted {
localMessage.Status = serverMessage.Status
} else {
localMessage.Status = constant.MsgStatusSendSuccess
}

if serverMessage.SessionType == constant.WriteGroupChatType || serverMessage.SessionType == constant.ReadGroupChatType {
localMessage.RecvID = serverMessage.GroupID
}
Expand Down
4 changes: 2 additions & 2 deletions internal/conversation_msg/message_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ func (c *Conversation) pullMessageIntoTable(ctx context.Context, pullMsgData map
log.ZDebug(ctx, "msg detail", "msg", v, "conversationID", conversationID)
//When the message has been marked and deleted by the cloud, it is directly inserted locally
//without any conversation and message update.
msg := MsgDataToLocalChatLog(v)
if v.Status == constant.MsgStatusHasDeleted {
insertMessage = append(insertMessage, MsgDataToLocalChatLog(v))
insertMessage = append(insertMessage, msg)
continue
}
msg := MsgDataToLocalChatLog(v)
// The message might be a filler provided by the server due to a gap in the sequence.
if msg.ClientMsgID == "" {
msg.ClientMsgID = utils.GetMsgID(c.loginUserID) + utils.Int64ToString(msg.Seq)
Expand Down

0 comments on commit 9270ddc

Please sign in to comment.