@@ -103,6 +103,16 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
103
103
operationID := c2v .Value .(sdk_struct.CmdNewMsgComeToConversation ).OperationID
104
104
allMsg := c2v .Value .(sdk_struct.CmdNewMsgComeToConversation ).MsgList
105
105
syncFlag := c2v .Value .(sdk_struct.CmdNewMsgComeToConversation ).SyncFlag
106
+ if c .msgListener == nil || c .ConversationListener == nil {
107
+ for _ , v := range allMsg {
108
+ if v .ContentType > constant .SignalingNotificationBegin && v .ContentType < constant .SignalingNotificationEnd {
109
+ log .Info (operationID , "signaling DoNotification " , v , "signaling:" , c .signaling )
110
+ c .signaling .DoNotification (v , c .GetCh (), operationID )
111
+ } else {
112
+ log .Info (operationID , "listener is nil, do nothing " , v )
113
+ }
114
+ }
115
+ }
106
116
if c .msgListener == nil {
107
117
log .Error (operationID , "not set c MsgListenerList" )
108
118
return
@@ -118,6 +128,7 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
118
128
var isTriggerUnReadCount bool
119
129
var insertMsg , updateMsg []* model_struct.LocalChatLog
120
130
var exceptionMsg []* model_struct.LocalErrChatLog
131
+ var unreadMessages []* model_struct.LocalConversationUnreadMessage
121
132
var newMessages , msgReadList , groupMsgReadList , msgRevokeList , newMsgRevokeList sdk_struct.NewMsgList
122
133
var isUnreadCount , isConversationUpdate , isHistory , isNotPrivate , isSenderConversationUpdate , isSenderNotificationPush bool
123
134
conversationChangedSet := make (map [string ]* model_struct.LocalConversation )
@@ -188,6 +199,7 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
188
199
log .Debug (operationID , "ConversationUnreadNotification come here" , unreadArgs .String ())
189
200
for _ , v := range unreadArgs .ConversationIDList {
190
201
c .doUpdateConversation (common.Cmd2Value {Value : common.UpdateConNode {ConID : v , Action : constant .UnreadCountSetZero }})
202
+ c .db .DeleteConversationUnreadMessageList (v , unreadArgs .UpdateUnreadCountTime )
191
203
}
192
204
c .doUpdateConversation (common.Cmd2Value {Value : common.UpdateConNode {Action : constant .ConChange , Args : unreadArgs .ConversationIDList }})
193
205
continue
@@ -251,23 +263,12 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
251
263
case constant .SingleChatType :
252
264
lc .ConversationID = utils .GetConversationIDBySessionType (v .RecvID , constant .SingleChatType )
253
265
lc .UserID = v .RecvID
254
- //localUserInfo,_ := c.user.GetLoginUser()
255
- //c.FaceURL = localUserInfo.FaceUrl
256
- //c.ShowName = localUserInfo.Nickname
257
266
case constant .GroupChatType :
258
267
lc .GroupID = v .GroupID
259
268
lc .ConversationID = utils .GetConversationIDBySessionType (lc .GroupID , constant .GroupChatType )
260
269
case constant .SuperGroupChatType :
261
270
lc .GroupID = v .GroupID
262
271
lc .ConversationID = utils .GetConversationIDBySessionType (lc .GroupID , constant .SuperGroupChatType )
263
- //faceUrl, name, err := u.getGroupNameAndFaceUrlByUid(c.GroupID)
264
- //if err != nil {
265
- // utils.sdkLog("getGroupNameAndFaceUrlByUid err:", err)
266
- //} else {
267
- // c.ShowName = name
268
- // c.FaceURL = faceUrl
269
- //}
270
-
271
272
}
272
273
if isConversationUpdate {
273
274
if isSenderConversationUpdate {
@@ -329,6 +330,8 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
329
330
if msg .SendTime > cacheConversation .UpdateUnreadCountTime {
330
331
isTriggerUnReadCount = true
331
332
lc .UnreadCount = 1
333
+ tempUnreadMessages := model_struct.LocalConversationUnreadMessage {ConversationID : lc .ConversationID , ClientMsgID : msg .ClientMsgID , SendTime : msg .SendTime }
334
+ unreadMessages = append (unreadMessages , & tempUnreadMessages )
332
335
}
333
336
}
334
337
if isConversationUpdate {
@@ -456,7 +459,10 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
456
459
}
457
460
b7 := utils .GetCurrentTimestampByMill ()
458
461
log .Debug (operationID , "BatchInsertConversationList, cost time : " , b7 - b6 )
459
-
462
+ unreadMessageErr := c .db .BatchInsertConversationUnreadMessageList (unreadMessages )
463
+ if unreadMessageErr != nil {
464
+ log .Error (operationID , "insert BatchInsertConversationUnreadMessageList err:" , unreadMessageErr .Error ())
465
+ }
460
466
c .doMsgReadState (msgReadList )
461
467
b8 := utils .GetCurrentTimestampByMill ()
462
468
log .Debug (operationID , "doMsgReadState cost time : " , b8 - b7 )
@@ -516,6 +522,7 @@ func (c *Conversation) doSuperGroupMsgNew(c2v common.Cmd2Value) {
516
522
var isTriggerUnReadCount bool
517
523
var insertMsg , updateMsg , specialUpdateMsg []* model_struct.LocalChatLog
518
524
var exceptionMsg []* model_struct.LocalErrChatLog
525
+ var unreadMessages []* model_struct.LocalConversationUnreadMessage
519
526
var newMessages , msgReadList , groupMsgReadList , msgRevokeList , newMsgRevokeList sdk_struct.NewMsgList
520
527
var isUnreadCount , isConversationUpdate , isHistory , isNotPrivate , isSenderConversationUpdate , isSenderNotificationPush bool
521
528
conversationChangedSet := make (map [string ]* model_struct.LocalConversation )
@@ -585,6 +592,7 @@ func (c *Conversation) doSuperGroupMsgNew(c2v common.Cmd2Value) {
585
592
_ = proto .Unmarshal (tips .Detail , & unreadArgs )
586
593
for _ , v := range unreadArgs .ConversationIDList {
587
594
c .doUpdateConversation (common.Cmd2Value {Value : common.UpdateConNode {ConID : v , Action : constant .UnreadCountSetZero }})
595
+ c .db .DeleteConversationUnreadMessageList (v , unreadArgs .UpdateUnreadCountTime )
588
596
}
589
597
c .doUpdateConversation (common.Cmd2Value {Value : common.UpdateConNode {Action : constant .ConChange , Args : unreadArgs .ConversationIDList }})
590
598
continue
@@ -730,6 +738,8 @@ func (c *Conversation) doSuperGroupMsgNew(c2v common.Cmd2Value) {
730
738
if msg .SendTime > cacheConversation .UpdateUnreadCountTime {
731
739
isTriggerUnReadCount = true
732
740
lc .UnreadCount = 1
741
+ tempUnreadMessages := model_struct.LocalConversationUnreadMessage {ConversationID : lc .ConversationID , ClientMsgID : msg .ClientMsgID , SendTime : msg .SendTime }
742
+ unreadMessages = append (unreadMessages , & tempUnreadMessages )
733
743
}
734
744
}
735
745
if isConversationUpdate {
@@ -865,7 +875,10 @@ func (c *Conversation) doSuperGroupMsgNew(c2v common.Cmd2Value) {
865
875
}
866
876
b7 := utils .GetCurrentTimestampByMill ()
867
877
log .Debug (operationID , "BatchInsertConversationList, cost time : " , b7 - b6 )
868
-
878
+ unreadMessageErr := c .db .BatchInsertConversationUnreadMessageList (unreadMessages )
879
+ if unreadMessageErr != nil {
880
+ log .Error (operationID , "insert BatchInsertConversationUnreadMessageList err:" , unreadMessageErr .Error ())
881
+ }
869
882
c .doMsgReadState (msgReadList )
870
883
b8 := utils .GetCurrentTimestampByMill ()
871
884
log .Debug (operationID , "doMsgReadState cost time : " , b8 - b7 )
0 commit comments