@@ -269,9 +269,9 @@ func (c *Conversation) pullMessageIntoTable(ctx context.Context, pullMsgData map
269
269
}
270
270
}
271
271
272
- insertMsg [conversationID ] = append (insertMessage , c .faceURLAndNicknameHandle (ctx , selfInsertMessage , othersInsertMessage , conversationID )... )
273
- updateMsg [conversationID ] = updateMessage
274
272
}
273
+ insertMsg [conversationID ] = append (insertMessage , c .faceURLAndNicknameHandle (ctx , selfInsertMessage , othersInsertMessage , conversationID )... )
274
+ updateMsg [conversationID ] = updateMessage
275
275
276
276
//update message
277
277
if err6 := c .messageController .BatchUpdateMessageList (ctx , updateMsg ); err6 != nil {
@@ -326,9 +326,11 @@ func (c *Conversation) singleHandle(ctx context.Context, self, others []*model_s
326
326
}
327
327
func (c * Conversation ) groupHandle (ctx context.Context , self , others []* model_struct.LocalChatLog , lc * model_struct.LocalConversation ) {
328
328
allMessage := append (self , others ... )
329
- localGroupMemberInfo , err := c .group .GetSpecifiedGroupMembersInfo (ctx , lc .GroupID , datautil .Slice (allMessage , func (e * model_struct.LocalChatLog ) string {
329
+
330
+ allSenders := datautil .Slice (allMessage , func (e * model_struct.LocalChatLog ) string {
330
331
return e .SendID
331
- }))
332
+ })
333
+ localGroupMemberInfo , err := c .group .GetSpecifiedGroupMembersInfo (ctx , lc .GroupID , datautil .Distinct (allSenders ))
332
334
if err != nil {
333
335
log .ZError (ctx , "get group member info err" , err )
334
336
return
@@ -337,11 +339,20 @@ func (c *Conversation) groupHandle(ctx context.Context, self, others []*model_st
337
339
return e .UserID
338
340
})
339
341
for _ , chatLog := range allMessage {
340
- if g , ok := groupMap [chatLog .SendID ]; ok {
342
+ if g , ok := groupMap [chatLog .SendID ]; ok { // If group member info is successfully retrieved
341
343
if g .FaceURL != "" && g .Nickname != "" {
342
344
chatLog .SenderFaceURL = g .FaceURL
343
345
chatLog .SenderNickname = g .Nickname
344
346
}
347
+ } else { // Otherwise, retrieve from local temporary cache
348
+ faceURL , name , err := c .getUserNameAndFaceURL (ctx , chatLog .SendID )
349
+ if err != nil {
350
+ log .ZWarn (ctx , "getUserNameAndFaceURL error" , err , "senderID" , chatLog .SendID )
351
+ } else if faceURL != "" && name != "" {
352
+ chatLog .SenderFaceURL = faceURL
353
+ chatLog .SenderNickname = name
354
+ }
345
355
}
346
356
}
357
+
347
358
}
0 commit comments