@@ -203,10 +203,8 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
203
203
var isTriggerUnReadCount bool
204
204
insertMsg := make (map [string ][]* model_struct.LocalChatLog , 10 )
205
205
updateMsg := make (map [string ][]* model_struct.LocalChatLog , 10 )
206
- var exceptionMsg []* model_struct.LocalErrChatLog
207
- //var unreadMessages []*model_struct.LocalConversationUnreadMessage
206
+ var exceptionMsg []* model_struct.LocalChatLog
208
207
var newMessages sdk_struct.NewMsgList
209
- // var reactionMsgModifierList, reactionMsgDeleterList sdk_struct.NewMsgList
210
208
211
209
var isUnreadCount , isConversationUpdate , isHistory , isNotPrivate , isSenderConversationUpdate bool
212
210
@@ -249,7 +247,10 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
249
247
250
248
//When the message has been marked and deleted by the cloud, it is directly inserted locally without any conversation and message update.
251
249
if msg .Status == constant .MsgStatusHasDeleted {
252
- insertMessage = append (insertMessage , MsgStructToLocalChatLog (msg ))
250
+ dbMessage := MsgStructToLocalChatLog (msg )
251
+ c .handleExceptionMessages (ctx , nil , dbMessage )
252
+ exceptionMsg = append (exceptionMsg , dbMessage )
253
+ insertMessage = append (insertMessage , dbMessage )
253
254
continue
254
255
}
255
256
@@ -265,10 +266,6 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
265
266
if ! isNotPrivate {
266
267
msg .AttachedInfoElem .IsPrivateChat = true
267
268
}
268
- if msg .ClientMsgID == "" {
269
- exceptionMsg = append (exceptionMsg , c .msgStructToLocalErrChatLog (msg ))
270
- continue
271
- }
272
269
if conversationID == "" {
273
270
log .ZError (ctx , "conversationID is empty" , errors .New ("conversationID is empty" ), "msg" , msg )
274
271
continue
@@ -281,16 +278,19 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
281
278
log .ZDebug (ctx , "decode message" , "msg" , msg )
282
279
if v .SendID == c .loginUserID { //seq
283
280
// Messages sent by myself //if sent through this terminal
284
- m , err := c .db .GetMessage (ctx , conversationID , msg .ClientMsgID )
281
+ existingMsg , err := c .db .GetMessage (ctx , conversationID , msg .ClientMsgID )
285
282
if err == nil {
286
283
log .ZInfo (ctx , "have message" , "msg" , msg )
287
- if m .Seq == 0 {
284
+ if existingMsg .Seq == 0 {
288
285
if ! isConversationUpdate {
289
286
msg .Status = constant .MsgStatusFiltered
290
287
}
291
288
updateMessage = append (updateMessage , MsgStructToLocalChatLog (msg ))
292
289
} else {
293
- exceptionMsg = append (exceptionMsg , c .msgStructToLocalErrChatLog (msg ))
290
+ dbMessage := MsgStructToLocalChatLog (msg )
291
+ c .handleExceptionMessages (ctx , existingMsg , dbMessage )
292
+ insertMessage = append (insertMessage , dbMessage )
293
+ exceptionMsg = append (exceptionMsg , dbMessage )
294
294
}
295
295
} else {
296
296
log .ZInfo (ctx , "sync message" , "msg" , msg )
@@ -318,7 +318,7 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
318
318
}
319
319
}
320
320
} else { //Sent by others
321
- if _ , err := c .db .GetMessage (ctx , conversationID , msg .ClientMsgID ); err != nil { //Deduplication operation
321
+ if existingMsg , err := c .db .GetMessage (ctx , conversationID , msg .ClientMsgID ); err != nil {
322
322
lc := model_struct.LocalConversation {
323
323
ConversationType : v .SessionType ,
324
324
LatestMsg : utils .StructToJsonString (msg ),
@@ -352,11 +352,10 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
352
352
}
353
353
354
354
} else {
355
- exceptionMsg = append (exceptionMsg , c .msgStructToLocalErrChatLog (msg ))
356
- log .ZWarn (ctx , "Deduplication operation " , nil , "msg" , * c .msgStructToLocalErrChatLog (msg ))
357
- msg .Status = constant .MsgStatusFiltered
358
- msg .ClientMsgID = msg .ClientMsgID + utils .Int64ToString (msg .Seq )
359
- othersInsertMessage = append (othersInsertMessage , MsgStructToLocalChatLog (msg ))
355
+ dbMessage := MsgStructToLocalChatLog (msg )
356
+ c .handleExceptionMessages (ctx , existingMsg , dbMessage )
357
+ insertMessage = append (insertMessage , dbMessage )
358
+ exceptionMsg = append (exceptionMsg , dbMessage )
360
359
}
361
360
}
362
361
}
@@ -451,6 +450,10 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
451
450
}
452
451
}
453
452
}
453
+ //Exception message storage
454
+ for _ , v := range exceptionMsg {
455
+ log .ZWarn (ctx , "exceptionMsg show: " , nil , "msg" , * v )
456
+ }
454
457
455
458
log .ZDebug (ctx , "insert msg" , "duration" , fmt .Sprintf ("%dms" , time .Since (b )), "len" , len (allMsg ))
456
459
}
@@ -464,6 +467,7 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
464
467
465
468
insertMsg := make (map [string ][]* model_struct.LocalChatLog , 10 )
466
469
conversationList := make ([]* model_struct.LocalConversation , 0 )
470
+ var exceptionMsg []* model_struct.LocalChatLog
467
471
468
472
log .ZDebug (ctx , "message come here conversation ch in reinstalled" , "conversation length" , msgLen )
469
473
b := time .Now ()
@@ -490,7 +494,10 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
490
494
491
495
//When the message has been marked and deleted by the cloud, it is directly inserted locally without any conversation and message update.
492
496
if msg .Status == constant .MsgStatusHasDeleted {
493
- insertMessage = append (insertMessage , MsgStructToLocalChatLog (msg ))
497
+ dbMessage := MsgStructToLocalChatLog (msg )
498
+ c .handleExceptionMessages (ctx , nil , dbMessage )
499
+ exceptionMsg = append (exceptionMsg , dbMessage )
500
+ insertMessage = append (insertMessage , dbMessage )
494
501
continue
495
502
}
496
503
msg .Status = constant .MsgStatusSendSuccess
@@ -545,6 +552,10 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
545
552
546
553
// log.ZDebug(ctx, "progress is", "msgLen", msgLen, "msgOffset", c.msgOffset, "total", total, "now progress is", (c.msgOffset*(100-InitSyncProgress))/total + InitSyncProgress)
547
554
c .ConversationListener ().OnSyncServerProgress ((c .msgOffset * (100 - InitSyncProgress ))/ total + InitSyncProgress )
555
+ //Exception message storage
556
+ for _ , v := range exceptionMsg {
557
+ log .ZWarn (ctx , "exceptionMsg show: " , nil , "msg" , * v )
558
+ }
548
559
}
549
560
550
561
func (c * Conversation ) addInitProgress (progress int ) {
@@ -606,15 +617,6 @@ func (c *Conversation) genConversationGroupAtType(lc *model_struct.LocalConversa
606
617
}
607
618
}
608
619
609
- func (c * Conversation ) msgStructToLocalErrChatLog (m * sdk_struct.MsgStruct ) * model_struct.LocalErrChatLog {
610
- var lc model_struct.LocalErrChatLog
611
- copier .Copy (& lc , m )
612
- if m .SessionType == constant .WriteGroupChatType || m .SessionType == constant .ReadGroupChatType {
613
- lc .RecvID = m .GroupID
614
- }
615
- return & lc
616
- }
617
-
618
620
func (c * Conversation ) batchUpdateMessageList (ctx context.Context , updateMsg map [string ][]* model_struct.LocalChatLog ) error {
619
621
if updateMsg == nil {
620
622
return nil
0 commit comments