mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 17:45:59 +08:00
send msg file modify
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
package im_mysql_msg_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
@@ -28,21 +29,27 @@ type ChatLog struct {
|
||||
Remark sql.NullString `gorm:"column:remark"` // remark
|
||||
}
|
||||
|
||||
func InsertMessageToChatLog(msgData pbMsg.WSToMsgSvrChatMsg) error {
|
||||
func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chatLog := ChatLog{
|
||||
MsgId: msgData.MsgID,
|
||||
SendID: msgData.SendID,
|
||||
RecvID: msgData.RecvID,
|
||||
SendTime: utils.UnixNanoSecondToTime(msgData.SendTime),
|
||||
SessionType: msgData.SessionType,
|
||||
ContentType: msgData.ContentType,
|
||||
MsgFrom: msgData.MsgFrom,
|
||||
Content: msgData.Content,
|
||||
SenderPlatformID: msgData.PlatformID,
|
||||
MsgId: msg.MsgData.ServerMsgID,
|
||||
SendID: msg.MsgData.SendID,
|
||||
SendTime: utils.UnixNanoSecondToTime(msg.MsgData.SendTime),
|
||||
SessionType: msg.MsgData.SessionType,
|
||||
ContentType: msg.MsgData.ContentType,
|
||||
MsgFrom: msg.MsgData.MsgFrom,
|
||||
Content: string(msg.MsgData.Content),
|
||||
SenderPlatformID: msg.MsgData.SenderPlatformID,
|
||||
}
|
||||
switch msg.MsgData.SessionType {
|
||||
case constant.GroupChatType:
|
||||
chatLog.RecvID = msg.MsgData.GroupID
|
||||
case constant.SingleChatType:
|
||||
chatLog.RecvID = msg.MsgData.RecvID
|
||||
}
|
||||
|
||||
return dbConn.Table("chat_log").Create(chatLog).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user