Skip to content

Commit fdc97c6

Browse files
authored
fix: when fetching a referenced message, it indicates that the original message has been deleted. (#2977)
* pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke
1 parent 1c35db7 commit fdc97c6

File tree

1 file changed

+44
-8
lines changed
  • pkg/common/storage/controller

1 file changed

+44
-8
lines changed

pkg/common/storage/controller/msg.go

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversat
269269
}
270270
return totalMsgs, nil
271271
}
272-
273272
func (db *commonMsgDatabase) handlerDBMsg(ctx context.Context, cache map[int64][]*model.MsgInfoModel, userID, conversationID string, msg *model.MsgInfoModel) {
274273
if msg.IsRead {
275274
msg.Msg.IsRead = true
@@ -280,16 +279,53 @@ func (db *commonMsgDatabase) handlerDBMsg(ctx context.Context, cache map[int64][
280279
if msg.Msg.Content == "" {
281280
return
282281
}
282+
type MsgData struct {
283+
SendID string `json:"sendID"`
284+
RecvID string `json:"recvID"`
285+
GroupID string `json:"groupID"`
286+
ClientMsgID string `json:"clientMsgID"`
287+
ServerMsgID string `json:"serverMsgID"`
288+
SenderPlatformID int32 `json:"senderPlatformID"`
289+
SenderNickname string `json:"senderNickname"`
290+
SenderFaceURL string `json:"senderFaceURL"`
291+
SessionType int32 `json:"sessionType"`
292+
MsgFrom int32 `json:"msgFrom"`
293+
ContentType int32 `json:"contentType"`
294+
Content string `json:"content"`
295+
Seq int64 `json:"seq"`
296+
SendTime int64 `json:"sendTime"`
297+
CreateTime int64 `json:"createTime"`
298+
Status int32 `json:"status"`
299+
IsRead bool `json:"isRead"`
300+
Options map[string]bool `json:"options,omitempty"`
301+
OfflinePushInfo *sdkws.OfflinePushInfo `json:"offlinePushInfo"`
302+
AtUserIDList []string `json:"atUserIDList"`
303+
AttachedInfo string `json:"attachedInfo"`
304+
Ex string `json:"ex"`
305+
KeyVersion int32 `json:"keyVersion"`
306+
DstUserIDs []string `json:"dstUserIDs"`
307+
}
283308
var quoteMsg struct {
284309
Text string `json:"text,omitempty"`
285-
QuoteMessage *sdkws.MsgData `json:"quoteMessage,omitempty"`
310+
QuoteMessage *MsgData `json:"quoteMessage,omitempty"`
286311
MessageEntityList json.RawMessage `json:"messageEntityList,omitempty"`
287312
}
288313
if err := json.Unmarshal([]byte(msg.Msg.Content), &quoteMsg); err != nil {
289314
log.ZError(ctx, "json.Unmarshal", err)
290315
return
291316
}
292-
if quoteMsg.QuoteMessage == nil || quoteMsg.QuoteMessage.ContentType == constant.MsgRevokeNotification {
317+
if quoteMsg.QuoteMessage == nil || quoteMsg.QuoteMessage.Content == "" {
318+
return
319+
}
320+
if quoteMsg.QuoteMessage.Content == "e30=" {
321+
quoteMsg.QuoteMessage.Content = "{}"
322+
data, err := json.Marshal(&quoteMsg)
323+
if err != nil {
324+
return
325+
}
326+
msg.Msg.Content = string(data)
327+
}
328+
if quoteMsg.QuoteMessage.Seq <= 0 && quoteMsg.QuoteMessage.ContentType == constant.MsgRevokeNotification {
293329
return
294330
}
295331
var msgs []*model.MsgInfoModel
@@ -311,19 +347,19 @@ func (db *commonMsgDatabase) handlerDBMsg(ctx context.Context, cache map[int64][
311347
}
312348
quoteMsg.QuoteMessage.ContentType = constant.MsgRevokeNotification
313349
if len(msgs) > 0 {
314-
quoteMsg.QuoteMessage.Content = []byte(msgs[0].Msg.Content)
350+
quoteMsg.QuoteMessage.Content = msgs[0].Msg.Content
315351
} else {
316-
quoteMsg.QuoteMessage.Content = []byte("{}")
352+
quoteMsg.QuoteMessage.Content = "{}"
317353
}
318354
data, err := json.Marshal(&quoteMsg)
319355
if err != nil {
320356
log.ZError(ctx, "json.Marshal", err)
321357
return
322358
}
323359
msg.Msg.Content = string(data)
324-
if _, err := db.msgDocDatabase.UpdateMsg(ctx, db.msgTable.GetDocID(conversationID, msg.Msg.Seq), db.msgTable.GetMsgIndex(msg.Msg.Seq), "msg", msg.Msg); err != nil {
325-
log.ZError(ctx, "UpdateMsgContent", err)
326-
}
360+
//if _, err := db.msgDocDatabase.UpdateMsg(ctx, db.msgTable.GetDocID(conversationID, msg.Msg.Seq), db.msgTable.GetMsgIndex(msg.Msg.Seq), "msg", msg.Msg); err != nil {
361+
// log.ZError(ctx, "UpdateMsgContent", err)
362+
//}
327363
}
328364

329365
func (db *commonMsgDatabase) findMsgInfoBySeq(ctx context.Context, userID, docID string, conversationID string, seqs []int64) (totalMsgs []*model.MsgInfoModel, err error) {

0 commit comments

Comments
 (0)