mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-22 21:09:20 +08:00
pb change
This commit is contained in:
parent
aaf834a33b
commit
d6ec8f4930
@ -49,7 +49,7 @@ func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.UserSend
|
||||
RecvID: params.Data.RecvID,
|
||||
ForceList: params.Data.ForceList,
|
||||
Content: params.Data.Content,
|
||||
Options: params.Data.Options,
|
||||
Options: utils.MapIntToJsonString(params.Data.Options),
|
||||
ClientMsgID: params.Data.ClientMsgID,
|
||||
OffLineInfo: utils.MapToJsonString(params.Data.OffLineInfo),
|
||||
Ex: utils.MapToJsonString(params.Data.Ex),
|
||||
|
@ -72,7 +72,7 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
|
||||
ForceList: params.ForceList,
|
||||
Content: newContent,
|
||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||
Options: options,
|
||||
Options: utils.MapIntToJsonString(options),
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
||||
SenderNickName: data.SenderNickName,
|
||||
SenderFaceURL: data.SenderFaceURL,
|
||||
Content: data.Content,
|
||||
Options: data.Options,
|
||||
Options: utils.MapIntToJsonString(data.Options),
|
||||
ClientMsgID: data.ClientMsgID,
|
||||
SendTime: sendTime,
|
||||
}
|
||||
|
@ -54,10 +54,11 @@ func (mc *HistoryConsumerHandler) handleChatWs2Mongo(msg []byte, msgKey string)
|
||||
pbSaveData.OperationID = pbData.OperationID
|
||||
pbSaveData.RecvID = pbData.RecvID
|
||||
pbSaveData.PlatformID = pbData.PlatformID
|
||||
options := utils.JsonStringToMap(pbData.Options)
|
||||
//Control whether to store offline messages (mongo)
|
||||
isHistory := utils.GetSwitchFromOptions(pbData.Options, "history")
|
||||
isHistory := utils.GetSwitchFromOptions(options, "history")
|
||||
//Control whether to store history messages (mysql)
|
||||
isPersist := utils.GetSwitchFromOptions(pbData.Options, "persistent")
|
||||
isPersist := utils.GetSwitchFromOptions(options, "persistent")
|
||||
switch pbData.SessionType {
|
||||
case constant.SingleChatType:
|
||||
log.NewDebug(pbSaveData.OperationID, "msg_transfer chat type = SingleChatType", isHistory, isPersist)
|
||||
|
@ -40,8 +40,9 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(msg []byte, msgKey strin
|
||||
log.ErrorByKv("msg_transfer Unmarshal chat err", "", "chat", string(msg), "err", err.Error())
|
||||
return
|
||||
}
|
||||
options := utils.JsonStringToMap(pbData.Options)
|
||||
//Control whether to store history messages (mysql)
|
||||
isPersist := utils.GetSwitchFromOptions(pbData.Options, "persistent")
|
||||
isPersist := utils.GetSwitchFromOptions(options, "persistent")
|
||||
//Only process receiver data
|
||||
if isPersist {
|
||||
if msgKey == pbData.RecvID && pbData.SessionType == constant.SingleChatType {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbRelay "Open_IM/pkg/proto/relay"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
@ -53,7 +54,7 @@ func (ms *PushConsumerHandler) handleMs2PsChat(msg []byte) {
|
||||
sendPbData.PlatformID = pbData.PlatformID
|
||||
sendPbData.RecvSeq = pbData.RecvSeq
|
||||
//Call push module to send message to the user
|
||||
MsgToUser(&sendPbData, pbData.OfflineInfo, pbData.Options)
|
||||
MsgToUser(&sendPbData, pbData.OfflineInfo, utils.JsonStringToMap(pbData.Options))
|
||||
}
|
||||
func (PushConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||
func (PushConsumerHandler) Cleanup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||
|
@ -71,7 +71,8 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*
|
||||
} else {
|
||||
pbData.SendTime = pb.SendTime
|
||||
}
|
||||
isHistory := utils.GetSwitchFromOptions(pbData.Options, "history")
|
||||
options := utils.JsonStringToMap(pbData.Options)
|
||||
isHistory := utils.GetSwitchFromOptions(options, "history")
|
||||
mReq := MsgCallBackReq{
|
||||
SendID: pb.SendID,
|
||||
RecvID: pb.RecvID,
|
||||
@ -237,10 +238,12 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i
|
||||
case constant.NotReceiveMessage:
|
||||
return false
|
||||
case constant.ReceiveNotNotifyMessage:
|
||||
if msg.Options == nil {
|
||||
msg.Options = make(map[string]int32, 2)
|
||||
options := utils.JsonStringToMap(msg.Options)
|
||||
if options == nil {
|
||||
options = make(map[string]int32, 2)
|
||||
}
|
||||
utils.SetSwitchFromOptions(msg.Options, "offlinePush", 0)
|
||||
utils.SetSwitchFromOptions(options, "offlinePush", 0)
|
||||
msg.Options = utils.MapIntToJsonString(options)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -198,14 +198,14 @@ func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgSvrToPu
|
||||
return errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
log.NewInfo("", "get mgoSession cost time", getCurrentTimestampByMill()-newTime)
|
||||
log.NewDebug("", "get mgoSession cost time", getCurrentTimestampByMill()-newTime)
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
seqUid = getSeqUid(uid, m.RecvSeq)
|
||||
n, err := c.Find(bson.M{"uid": seqUid}).Count()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.NewInfo("", "find mgo uid cost time", getCurrentTimestampByMill()-newTime)
|
||||
log.NewDebug("", "find mgo uid cost time", getCurrentTimestampByMill()-newTime)
|
||||
sMsg := MsgInfo{}
|
||||
sMsg.SendTime = sendTime
|
||||
if sMsg.Msg, err = proto.Marshal(m); err != nil {
|
||||
@ -225,7 +225,7 @@ func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgSvrToPu
|
||||
return err
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "insert mgo data cost time", getCurrentTimestampByMill()-newTime)
|
||||
log.NewDebug("", "insert mgo data cost time", getCurrentTimestampByMill()-newTime)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ type PushMsgReq struct {
|
||||
OperationID string `protobuf:"bytes,9,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
MsgID string `protobuf:"bytes,10,opt,name=MsgID" json:"MsgID,omitempty"`
|
||||
OfflineInfo string `protobuf:"bytes,11,opt,name=OfflineInfo" json:"OfflineInfo,omitempty"`
|
||||
Options map[string]int32 `protobuf:"bytes,12,rep,name=Options" json:"Options,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
Options string `protobuf:"bytes,12,opt,name=Options" json:"Options,omitempty"`
|
||||
PlatformID int32 `protobuf:"varint,13,opt,name=PlatformID" json:"PlatformID,omitempty"`
|
||||
SenderNickName string `protobuf:"bytes,14,opt,name=SenderNickName" json:"SenderNickName,omitempty"`
|
||||
SenderFaceURL string `protobuf:"bytes,15,opt,name=SenderFaceURL" json:"SenderFaceURL,omitempty"`
|
||||
@ -49,7 +49,7 @@ func (m *PushMsgReq) Reset() { *m = PushMsgReq{} }
|
||||
func (m *PushMsgReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*PushMsgReq) ProtoMessage() {}
|
||||
func (*PushMsgReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_push_380e4afdaa5f6119, []int{0}
|
||||
return fileDescriptor_push_e44270f7d93180b9, []int{0}
|
||||
}
|
||||
func (m *PushMsgReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PushMsgReq.Unmarshal(m, b)
|
||||
@ -146,11 +146,11 @@ func (m *PushMsgReq) GetOfflineInfo() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetOptions() map[string]int32 {
|
||||
func (m *PushMsgReq) GetOptions() string {
|
||||
if m != nil {
|
||||
return m.Options
|
||||
}
|
||||
return nil
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetPlatformID() int32 {
|
||||
@ -192,7 +192,7 @@ func (m *PushMsgResp) Reset() { *m = PushMsgResp{} }
|
||||
func (m *PushMsgResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*PushMsgResp) ProtoMessage() {}
|
||||
func (*PushMsgResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_push_380e4afdaa5f6119, []int{1}
|
||||
return fileDescriptor_push_e44270f7d93180b9, []int{1}
|
||||
}
|
||||
func (m *PushMsgResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PushMsgResp.Unmarshal(m, b)
|
||||
@ -221,7 +221,6 @@ func (m *PushMsgResp) GetResultCode() int32 {
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PushMsgReq)(nil), "push.PushMsgReq")
|
||||
proto.RegisterMapType((map[string]int32)(nil), "push.PushMsgReq.OptionsEntry")
|
||||
proto.RegisterType((*PushMsgResp)(nil), "push.PushMsgResp")
|
||||
}
|
||||
|
||||
@ -297,35 +296,32 @@ var _PushMsgService_serviceDesc = grpc.ServiceDesc{
|
||||
Metadata: "push/push.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("push/push.proto", fileDescriptor_push_380e4afdaa5f6119) }
|
||||
func init() { proto.RegisterFile("push/push.proto", fileDescriptor_push_e44270f7d93180b9) }
|
||||
|
||||
var fileDescriptor_push_380e4afdaa5f6119 = []byte{
|
||||
// 426 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x5f, 0x6b, 0xdb, 0x30,
|
||||
0x14, 0xc5, 0x71, 0x13, 0x27, 0xed, 0x4d, 0xf3, 0x67, 0x62, 0x0c, 0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0x72, 0xfe, 0x1d, 0x46, 0xb5, 0x7d, 0x81, 0xe5, 0x36, 0x5f, 0x22,
|
||||
0x8b, 0xa1, 0x5f, 0x13, 0x36, 0x39, 0xcc, 0x6f, 0xfa, 0xea, 0x80, 0x18, 0xfd, 0x63, 0xfc, 0x67,
|
||||
0x18, 0xd3, 0x4a, 0x7f, 0xd3, 0xf7, 0x8e, 0xdf, 0xf7, 0x68, 0xb5, 0x3f, 0xff, 0x0b, 0x00, 0x00,
|
||||
0xff, 0xff, 0xf0, 0x9a, 0xaa, 0x81, 0xed, 0x02, 0x00, 0x00,
|
||||
var fileDescriptor_push_e44270f7d93180b9 = []byte{
|
||||
// 378 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x5d, 0xeb, 0xda, 0x30,
|
||||
0x14, 0xc6, 0xe9, 0xb4, 0xbe, 0x1c, 0xe7, 0xcb, 0xc2, 0x18, 0xc1, 0x8b, 0x51, 0x64, 0x0c, 0x6f,
|
||||
0xd6, 0xc1, 0x76, 0xb9, 0x9b, 0x31, 0x8b, 0x50, 0x98, 0x2f, 0xa4, 0xee, 0x66, 0x77, 0xb5, 0x9e,
|
||||
0x6a, 0x59, 0x9b, 0xc4, 0xa6, 0x0a, 0xfb, 0xd2, 0xfb, 0x0c, 0x23, 0x49, 0xd5, 0xfe, 0xbd, 0x29,
|
||||
0x7d, 0x7e, 0xe7, 0x39, 0x87, 0x27, 0xc9, 0x81, 0xb1, 0xbc, 0xa8, 0xd3, 0x67, 0xfd, 0xf1, 0x65,
|
||||
0x29, 0x2a, 0x41, 0xda, 0xfa, 0x7f, 0xf6, 0xaf, 0x05, 0xb0, 0xbd, 0xa8, 0xd3, 0x4a, 0x1d, 0x19,
|
||||
0x9e, 0xc9, 0x3b, 0xe8, 0x44, 0xc8, 0x0f, 0x61, 0x40, 0x1d, 0xcf, 0x99, 0xf7, 0x59, 0x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0x93, 0x8e, 0x8d,
|
||||
0xed, 0x25, 0x34, 0xb7, 0x94, 0x67, 0xc8, 0x2b, 0x7b, 0x8a, 0x89, 0x4d, 0xda, 0x40, 0xb3, 0x4f,
|
||||
0x30, 0xb8, 0xbf, 0xb7, 0x92, 0x3a, 0x1e, 0x43, 0x75, 0xc9, 0xab, 0x85, 0x38, 0xa0, 0x79, 0x74,
|
||||
0x97, 0x35, 0xc8, 0x97, 0xef, 0x30, 0xaa, 0xed, 0x11, 0x96, 0xd7, 0x2c, 0x41, 0xe2, 0x43, 0xb7,
|
||||
0x26, 0x64, 0xe2, 0x9b, 0x7d, 0x7a, 0xec, 0xcf, 0xf4, 0xcd, 0x13, 0x51, 0xf2, 0xc7, 0xf8, 0xf7,
|
||||
0xd0, 0x37, 0x7b, 0xf7, 0x4d, 0xee, 0x35, 0xdf, 0x77, 0xcc, 0xfe, 0x7d, 0xfd, 0x1f, 0x00, 0x00,
|
||||
0xff, 0xff, 0x6b, 0x53, 0xf4, 0xd4, 0x92, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ func MapIntToJsonString(param map[string]int32) string {
|
||||
dataString := string(dataType)
|
||||
return dataString
|
||||
}
|
||||
func JsonStringToMap(str string) (tempMap map[string]interface{}) {
|
||||
func JsonStringToMap(str string) (tempMap map[string]int32) {
|
||||
_ = json.Unmarshal([]byte(str), &tempMap)
|
||||
return tempMap
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user