|
|
|
@ -45,32 +45,20 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
|
|
|
|
|
isHistory := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsHistory)
|
|
|
|
|
//Control whether to store history messages (mysql)
|
|
|
|
|
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
|
|
|
|
|
isSenderSync := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsSenderSync)
|
|
|
|
|
//isSenderSync := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsSenderSync)
|
|
|
|
|
switch msgFromMQ.MsgData.SessionType {
|
|
|
|
|
case constant.SingleChatType:
|
|
|
|
|
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = SingleChatType", isHistory, isPersist)
|
|
|
|
|
if isHistory {
|
|
|
|
|
if msgKey == msgFromMQ.MsgData.RecvID {
|
|
|
|
|
err := saveUserChat(msgFromMQ.MsgData.RecvID, &msgFromMQ)
|
|
|
|
|
err := saveUserChat(msgKey, &msgFromMQ)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.RecvID)
|
|
|
|
|
log.NewDebug(msgFromMQ.OperationID, "sendMessageToPush cost time ", utils.GetCurrentTimestampByNano()-time)
|
|
|
|
|
|
|
|
|
|
} else if msgKey == msgFromMQ.MsgData.SendID {
|
|
|
|
|
err := saveUserChat(msgFromMQ.MsgData.SendID, &msgFromMQ)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.NewError(operationID, "single data insert to mongo err", err.Error(), msgFromMQ.String())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if isSenderSync {
|
|
|
|
|
go sendMessageToPush(&msgFromMQ, msgFromMQ.MsgData.SendID)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
go sendMessageToPush(&msgFromMQ, msgKey)
|
|
|
|
|
log.NewDebug(operationID, "saveUserChat cost time ", utils.GetCurrentTimestampByNano()-time)
|
|
|
|
|
}
|
|
|
|
|
case constant.GroupChatType:
|
|
|
|
|
log.NewDebug(msgFromMQ.OperationID, "msg_transfer msg type = GroupChatType", isHistory, isPersist)
|
|
|
|
|
if isHistory {
|
|
|
|
|