提交 63af5919 编写于 作者: W wenxu12345

Merge remote-tracking branch 'origin/tuoyun' into tuoyun

...@@ -44,6 +44,7 @@ const ( ...@@ -44,6 +44,7 @@ const (
GroupMsg = 201 GroupMsg = 201
//SysRelated //SysRelated
NotificationBegin = 1000
FriendApplicationApprovedNotification = 1201 //add_friend_response FriendApplicationApprovedNotification = 1201 //add_friend_response
FriendApplicationRejectedNotification = 1202 //add_friend_response FriendApplicationRejectedNotification = 1202 //add_friend_response
...@@ -66,6 +67,7 @@ const ( ...@@ -66,6 +67,7 @@ const (
MemberKickedNotification = 1508 MemberKickedNotification = 1508
MemberInvitedNotification = 1509 MemberInvitedNotification = 1509
MemberEnterNotification = 1510 MemberEnterNotification = 1510
NotificationEnd = 2000
//MsgFrom //MsgFrom
UserMsgType = 100 UserMsgType = 100
......
...@@ -10,7 +10,10 @@ import ( ...@@ -10,7 +10,10 @@ import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db" "Open_IM/pkg/common/db"
pbMsg "Open_IM/pkg/proto/chat" pbMsg "Open_IM/pkg/proto/chat"
"Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
) )
...@@ -27,7 +30,19 @@ func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error { ...@@ -27,7 +30,19 @@ func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error {
case constant.SingleChatType: case constant.SingleChatType:
chatLog.RecvID = msg.MsgData.RecvID chatLog.RecvID = msg.MsgData.RecvID
} }
chatLog.Content = string(msg.MsgData.Content) if msg.MsgData.ContentType >= constant.NotificationBegin && msg.MsgData.ContentType <= constant.NotificationEnd {
var tips server_api_params.TipsComm
_ = proto.Unmarshal(msg.MsgData.Content, &tips)
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
chatLog.Content, _ = marshaler.MarshalToString(&tips)
} else {
chatLog.Content = string(msg.MsgData.Content)
}
chatLog.CreateTime = utils.UnixMillSecondToTime(msg.MsgData.CreateTime) chatLog.CreateTime = utils.UnixMillSecondToTime(msg.MsgData.CreateTime)
chatLog.SendTime = utils.UnixMillSecondToTime(msg.MsgData.SendTime) chatLog.SendTime = utils.UnixMillSecondToTime(msg.MsgData.SendTime)
return dbConn.Table("chat_logs").Create(chatLog).Error return dbConn.Table("chat_logs").Create(chatLog).Error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册