Skip to content

Commit

Permalink
fix: online only message to trigger new messages. (#523)
Browse files Browse the repository at this point in the history
* fix: add the parameter "isOnlineOnly" to the "sendMessage" method.

* fix: add the parameter "isOnlineOnly" to the "sendMessage" method.

* fix: online only message to trigger new messages.

* fix: test file update.
  • Loading branch information
FGadvancer committed Feb 28, 2024
1 parent 079bb19 commit 29893ca
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 233 deletions.
13 changes: 5 additions & 8 deletions internal/conversation_msg/conversation_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
for _, v := range msgs.Msgs {
log.ZDebug(ctx, "parse message ", "conversationID", conversationID, "msg", v)
isHistory = utils.GetSwitchFromOptions(v.Options, constant.IsHistory)
if !isHistory {
onlineMap[onlineMsgKey{ClientMsgID: v.ClientMsgID, ServerMsgID: v.ServerMsgID}] = struct{}{}
}
isUnreadCount = utils.GetSwitchFromOptions(v.Options, constant.IsUnreadCount)
isConversationUpdate = utils.GetSwitchFromOptions(v.Options, constant.IsConversationUpdate)
isNotPrivate = utils.GetSwitchFromOptions(v.Options, constant.IsNotPrivate)
Expand Down Expand Up @@ -232,6 +229,11 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
log.ZError(ctx, "conversationID is empty", errors.New("conversationID is empty"), "msg", msg)
continue
}
if !isHistory {
onlineMap[onlineMsgKey{ClientMsgID: v.ClientMsgID, ServerMsgID: v.ServerMsgID}] = struct{}{}
newMessages = append(newMessages, msg)

}
log.ZDebug(ctx, "decode message", "msg", msg)
if v.SendID == c.loginUserID { //seq
// Messages sent by myself //if sent through this terminal
Expand Down Expand Up @@ -304,11 +306,6 @@ func (c *Conversation) doMsgNew(c2v common.Cmd2Value) {
if isHistory {
othersInsertMessage = append(othersInsertMessage, c.msgStructToLocalChatLog(msg))
}
switch msg.ContentType {
case constant.Typing:
newMessages = append(newMessages, msg)
default:
}

} else {
exceptionMsg = append(exceptionMsg, c.msgStructToLocalErrChatLog(msg))
Expand Down
Loading

0 comments on commit 29893ca

Please sign in to comment.