@@ -203,10 +203,8 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
203203 var isTriggerUnReadCount bool
204204 insertMsg := make (map [string ][]* model_struct.LocalChatLog , 10 )
205205 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
208207 var newMessages sdk_struct.NewMsgList
209- // var reactionMsgModifierList, reactionMsgDeleterList sdk_struct.NewMsgList
210208
211209 var isUnreadCount , isConversationUpdate , isHistory , isNotPrivate , isSenderConversationUpdate bool
212210
@@ -249,7 +247,10 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
249247
250248 //When the message has been marked and deleted by the cloud, it is directly inserted locally without any conversation and message update.
251249 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 )
253254 continue
254255 }
255256
@@ -265,10 +266,6 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
265266 if ! isNotPrivate {
266267 msg .AttachedInfoElem .IsPrivateChat = true
267268 }
268- if msg .ClientMsgID == "" {
269- exceptionMsg = append (exceptionMsg , c .msgStructToLocalErrChatLog (msg ))
270- continue
271- }
272269 if conversationID == "" {
273270 log .ZError (ctx , "conversationID is empty" , errors .New ("conversationID is empty" ), "msg" , msg )
274271 continue
@@ -281,16 +278,19 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
281278 log .ZDebug (ctx , "decode message" , "msg" , msg )
282279 if v .SendID == c .loginUserID { //seq
283280 // 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 )
285282 if err == nil {
286283 log .ZInfo (ctx , "have message" , "msg" , msg )
287- if m .Seq == 0 {
284+ if existingMsg .Seq == 0 {
288285 if ! isConversationUpdate {
289286 msg .Status = constant .MsgStatusFiltered
290287 }
291288 updateMessage = append (updateMessage , MsgStructToLocalChatLog (msg ))
292289 } 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 )
294294 }
295295 } else {
296296 log .ZInfo (ctx , "sync message" , "msg" , msg )
@@ -318,7 +318,7 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
318318 }
319319 }
320320 } 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 {
322322 lc := model_struct.LocalConversation {
323323 ConversationType : v .SessionType ,
324324 LatestMsg : utils .StructToJsonString (msg ),
@@ -352,11 +352,10 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
352352 }
353353
354354 } 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 )
360359 }
361360 }
362361 }
@@ -451,6 +450,10 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
451450 }
452451 }
453452 }
453+ //Exception message storage
454+ for _ , v := range exceptionMsg {
455+ log .ZWarn (ctx , "exceptionMsg show: " , nil , "msg" , * v )
456+ }
454457
455458 log .ZDebug (ctx , "insert msg" , "duration" , fmt .Sprintf ("%dms" , time .Since (b )), "len" , len (allMsg ))
456459}
@@ -464,6 +467,7 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
464467
465468 insertMsg := make (map [string ][]* model_struct.LocalChatLog , 10 )
466469 conversationList := make ([]* model_struct.LocalConversation , 0 )
470+ var exceptionMsg []* model_struct.LocalChatLog
467471
468472 log .ZDebug (ctx , "message come here conversation ch in reinstalled" , "conversation length" , msgLen )
469473 b := time .Now ()
@@ -490,7 +494,10 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
490494
491495 //When the message has been marked and deleted by the cloud, it is directly inserted locally without any conversation and message update.
492496 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 )
494501 continue
495502 }
496503 msg .Status = constant .MsgStatusSendSuccess
@@ -545,6 +552,10 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
545552
546553 // log.ZDebug(ctx, "progress is", "msgLen", msgLen, "msgOffset", c.msgOffset, "total", total, "now progress is", (c.msgOffset*(100-InitSyncProgress))/total + InitSyncProgress)
547554 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+ }
548559}
549560
550561func (c * Conversation ) addInitProgress (progress int ) {
@@ -606,15 +617,6 @@ func (c *Conversation) genConversationGroupAtType(lc *model_struct.LocalConversa
606617 }
607618}
608619
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-
618620func (c * Conversation ) batchUpdateMessageList (ctx context.Context , updateMsg map [string ][]* model_struct.LocalChatLog ) error {
619621 if updateMsg == nil {
620622 return nil
0 commit comments